feed

package
v0.0.0-...-1fbc8d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: BSD-2-Clause Imports: 23 Imported by: 0

README

Testing

Test successful punlic IP

TEST_PUBLIC_IP=$(curl ifconfig.io) go test -v ./...

Block remote service on linux

To test failing remote service, such as api.ipify.org, block all IPs of that FQDN with:

sudo iptables -t filter -A OUTPUT -p tcp -d 104.21.192.0/24 -j DROP
go test -v
sudo iptables -t filter -F OUTPUT
go test -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPictureByURL

func GetPictureByURL(fileURL string) telega.CommandHandler

GetPictureByURL serves an image from a remote URL.

func HandleCommandlTemp

func HandleCommandlTemp(ctx context.Context, cmd *tgbotapi.Message, _ *tgbotapi.BotAPI) (response telega.ChattableCloser, _ error)

HandlerCommandTemp reads temp from a sensor and reponds in a telegram message.

func MonitorDirectoryTree

func MonitorDirectoryTree(directory string, filter FilterFunc) telega.BackgroundFunction

MonitorDirectoryTree returns a function, which watches all subdirectories for changes, starting at directory.

The logic as following:

  • add top-level directory to the inotify watch list;
  • DirWalk top-level directory;
  • for each first-level subdirectory:
  • add to the inotify watch list;
  • queue for the DirWalk;
  • skip any second-level and below subdirs: they wlil be processed as a part of walking of their parents dirs;
  • for every inotify CREATE event, check if it's a directory created, then add to the inotify list and schedule for DirWalk;
  • if a dedupe algo is used (based on tracking what's been added to inotify watch list), do not add to the list and not queue for DirWalk.

Important! First, dir should be added to inotify list, then queued for DirWalk to avoid inherent race conditions with inotify mechanism.

func PingCommand

func PingCommand(ctx context.Context, cmd *tgbotapi.Message, _ *tgbotapi.BotAPI) (response telega.ChattableCloser, _ error)

PingCommand reads temp from a sensor and reponds in a telegram message.

func PublicIP

func PublicIP(ctx context.Context) (ipAddress string)

PublicIP returns current public IP of the system as a string. Returns emptry string if not changed or could not be determined.

func TemperatureMonitor

func TemperatureMonitor(ctx context.Context) string

TemperatureMonitor 's for temp changes over the threshold

Types

type FilterFunc

type FilterFunc func(fpath string) bool

FilterFunc accepts a filename and returns true of false if it's accepted for further processing

func FilenameFilter

func FilenameFilter(regexpPatterns []string) FilterFunc

FilenameFilter accepts an array of regexp string to match a file name against. The regexps in array must be valid. Returned is a filter function.

func NewfileFilterChain

func NewfileFilterChain(filter FilterFunc) FilterFunc

NewFileFilterChain returns true only if a file is created after the launch

func RatelimitFilterChain

func RatelimitFilterChain(oncePerDuration time.Duration, filter FilterFunc) FilterFunc

RatelimitFilterChain returns true only if file of the same MIME type updated in the same dir not more often than oncePerDuration

type IPv4

type IPv4 string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL