Documentation ¶
Index ¶
- func GetPictureByURL(fileURL string) telega.CommandHandler
- func HandleCommandlTemp(ctx context.Context, cmd *tgbotapi.Message, _ *tgbotapi.BotAPI) (response telega.ChattableCloser, _ error)
- func MonitorDirectoryTree(directory string, filter FilterFunc) telega.BackgroundFunction
- func PingCommand(ctx context.Context, cmd *tgbotapi.Message, _ *tgbotapi.BotAPI) (response telega.ChattableCloser, _ error)
- func PublicIP(ctx context.Context) (ipAddress string)
- func TemperatureMonitor(ctx context.Context) string
- type FilterFunc
- type IPv4
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 ¶
PublicIP returns current public IP of the system as a string. Returns emptry string if not changed or could not be determined.
func TemperatureMonitor ¶
TemperatureMonitor 's for temp changes over the threshold
Types ¶
type FilterFunc ¶
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