plugins

package
v0.0.0-...-88fbdb7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Plugins         sync.Map
	DisabledPlugins sync.Map
	Commands        sync.Map
	Bot             *tgbotapi.BotAPI
	DB              *sql.DB
	Config          *config.Config
)

Functions

func CheckIfPluginDisabled

func CheckIfPluginDisabled(name, state string) bool

func DisablePlugin

func DisablePlugin(plugin string) bool

Disable a plugin

func EnablePlugin

func EnablePlugin(plugin string) bool

Enable a plugin

func KeyOf

func KeyOf(p TelegramPlugin) string

KeyOf ...

func RegisterCommand

func RegisterCommand(command string, description string, roles []string, callback CommandCallback)

Register a Command exported by a plugin

func RegisterPlugin

func RegisterPlugin(p TelegramPlugin)

Register a Plugin

func UnregisterCommand

func UnregisterCommand(command string)

UnRegister a Command exported by a plugin

Types

type Command

type Command struct {
	Description string          `sql:"description"`
	Roles       map[string]bool `sql:"roles"`
	Callback    CommandCallback
}

Command ...

func (Command) IsAllowedForRole

func (cmd Command) IsAllowedForRole(role string) bool

type CommandCallback

type CommandCallback func(update *tgbotapi.Update, command, args string, user *database.User) error

type TelegramPlugin

type TelegramPlugin interface {
	OnStart()
	OnStop()
}

TelegramPlugin ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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