Documentation
¶
Overview ¶
Package plugin provides a plugin system for spam detection in tg-spam. It loads and executes Lua scripts that implement custom spam checking logic. Scripts should provide a "check" function that takes a message context and returns a boolean (is spam) and a string (details).
Index ¶
- type Check
- type Checker
- func (c *Checker) Close()
- func (c *Checker) GetAllChecks() map[string]Check
- func (c *Checker) GetCheck(name string) (Check, error)
- func (c *Checker) LoadDirectory(dir string) error
- func (c *Checker) LoadScript(path string) error
- func (c *Checker) RegisterHelpers()
- func (c *Checker) ReloadScript(path string) error
- func (c *Checker) SetWatcher(watcher *Watcher)
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Check ¶
Check is a function that takes a request and returns a response indicating if message is spam
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker implements a Lua plugin engine for spam detection
func (*Checker) GetAllChecks ¶
GetAllChecks returns all loaded Lua checks
func (*Checker) LoadDirectory ¶
LoadDirectory loads all Lua scripts from a directory
func (*Checker) LoadScript ¶
LoadScript loads a Lua script and registers it as a checker
func (*Checker) RegisterHelpers ¶
func (c *Checker) RegisterHelpers()
RegisterHelpers registers common helper functions for Lua scripts
func (*Checker) ReloadScript ¶
ReloadScript reloads a specific Lua script
func (*Checker) SetWatcher ¶
SetWatcher sets the file watcher for the Checker
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors a directory for changes to Lua scripts and reloads them as needed
func NewWatcher ¶
NewWatcher creates a new file system watcher for Lua plugins