plugin

package
v1.23.7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check func(req spamcheck.Request) spamcheck.Response

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 NewChecker

func NewChecker() *Checker

NewChecker creates a new Checker

func (*Checker) Close

func (c *Checker) Close()

Close cleans up resources used by the Checker

func (*Checker) GetAllChecks

func (c *Checker) GetAllChecks() map[string]Check

GetAllChecks returns all loaded Lua checks

func (*Checker) GetCheck

func (c *Checker) GetCheck(name string) (Check, error)

GetCheck returns a Check for the specified Lua checker

func (*Checker) LoadDirectory

func (c *Checker) LoadDirectory(dir string) error

LoadDirectory loads all Lua scripts from a directory

func (*Checker) LoadScript

func (c *Checker) LoadScript(path string) error

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

func (c *Checker) ReloadScript(path string) error

ReloadScript reloads a specific Lua script

func (*Checker) SetWatcher

func (c *Checker) SetWatcher(watcher *Watcher)

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

func NewWatcher(checker *Checker, pluginsDir string) (*Watcher, error)

NewWatcher creates a new file system watcher for Lua plugins

func (*Watcher) Start

func (w *Watcher) Start() error

Start begins watching the plugins directory for changes

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop terminates the file watcher

Jump to

Keyboard shortcuts

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