Documentation
¶
Index ¶
- type BotHost
- type Parser
- type Registry
- func (r *Registry) AddPrefix(prefix string)
- func (r *Registry) AddUserAlias(name, cmd string)
- func (r *Registry) CanUseCommands(userID int64) bool
- func (r *Registry) ExecuteCommand(ctx context.Context, msg *interfaces.MessageEvent, name string, args []string) error
- func (r *Registry) Get(name string) (*interfaces.Command, bool)
- func (r *Registry) GetAll() map[string]*interfaces.Command
- func (r *Registry) GetByPlugin(plugin string) map[string]*interfaces.Command
- func (r *Registry) GetPrefix() string
- func (r *Registry) GetPrefixes() []string
- func (r *Registry) Host() plugin.Host
- func (r *Registry) IsCommand(text string) bool
- func (r *Registry) ParseCommand(text string) (name string, args []string, ok bool)
- func (r *Registry) Register(cmd *interfaces.Command) error
- func (r *Registry) RemovePrefix(prefix string) bool
- func (r *Registry) RemoveUserAlias(name string)
- func (r *Registry) SetBot(b BotHost)
- func (r *Registry) SetMediaSender(m interfaces.MediaSender)
- func (r *Registry) SetOwnerID(id int64)
- func (r *Registry) SetPrefix(prefix string)
- func (r *Registry) SetPrefixes(prefixes []string)
- func (r *Registry) SetSelfID(id int64)
- func (r *Registry) SetSudoChecker(f func(int64) bool)
- func (r *Registry) Unregister(name string)
- func (r *Registry) UnregisterPlugin(plugin string)
- func (r *Registry) Use(mw interfaces.Middleware)
- func (r *Registry) UserAliases() map[string]string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotHost ¶ added in v0.1.1
type BotHost interface {
Settings(spec *plugin.SettingsSpec) (plugin.Settings, error)
For(plugin string) plugin.Bot
RemovePlugin(plugin string)
}
BotHost is what the registry needs from the companion bot service.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser listens for message events and dispatches commands. It handles the owner's outgoing messages plus, when sudo is enabled, messages from delegated users. Other people's traffic is ignored.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages command registration, lookup, and middleware execution. Supports multi-prefix command parsing.
func NewRegistry ¶
func NewRegistry(prefixes []string, emitter interfaces.Emitter, api *tg.Client, resolver interfaces.PeerResolver, ownerID int64, i18nMgr *i18n.Manager) *Registry
func (*Registry) AddUserAlias ¶
AddUserAlias registers a runtime alias. The alias value is a full command line (command plus optional fixed arguments) and is expanded exactly once during parsing; aliases do not nest.
func (*Registry) CanUseCommands ¶ added in v0.1.1
CanUseCommands reports whether a user may trigger commands at all: the owner (outgoing messages) or a sudo-enabled delegated user.
func (*Registry) ExecuteCommand ¶
func (r *Registry) ExecuteCommand(ctx context.Context, msg *interfaces.MessageEvent, name string, args []string) error
func (*Registry) GetByPlugin ¶
func (r *Registry) GetByPlugin(plugin string) map[string]*interfaces.Command
func (*Registry) GetPrefixes ¶
func (*Registry) Host ¶ added in v0.1.1
Host returns the plugin.Host view of the registry: the same services a CommandContext carries, usable outside command handlers.
func (*Registry) ParseCommand ¶
ParseCommand parses a command from text, trying all registered prefixes. Returns the first match across all prefixes.
func (*Registry) RemovePrefix ¶
RemovePrefix removes a prefix (keeps at least one).
func (*Registry) RemoveUserAlias ¶
RemoveUserAlias deletes a runtime alias.
func (*Registry) SetBot ¶ added in v0.1.1
SetBot wires the companion bot so plugins get settings and bot access.
func (*Registry) SetMediaSender ¶
func (r *Registry) SetMediaSender(m interfaces.MediaSender)
SetMediaSender wires the media manager so command handlers can send files.
func (*Registry) SetOwnerID ¶
SetOwnerID updates the owner ID after initial resolution.
func (*Registry) SetPrefixes ¶
SetPrefixes replaces all prefixes.
func (*Registry) SetSelfID ¶ added in v0.1.1
SetSelfID records the logged-in account id exposed as ctx.SelfID.
func (*Registry) SetSudoChecker ¶
SetSudoChecker wires a permission checker used to let delegated users run OwnerOnly commands.
func (*Registry) Unregister ¶
func (*Registry) UnregisterPlugin ¶
func (*Registry) Use ¶
func (r *Registry) Use(mw interfaces.Middleware)
func (*Registry) UserAliases ¶
UserAliases returns a copy of the runtime alias map.