command

package
v0.0.0-...-14802c6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser listens for message events and dispatches commands. As a userbot, the Parser only handles outgoing messages (IsOut == true). Incoming messages could be added for bot-style operation by removing the IsOut filter — this is a deliberate design choice for the userbot use case.

func NewParser

func NewParser(registry *Registry, bus *eventbus.Bus) *Parser

func (*Parser) Start

func (p *Parser) Start()

Start registers the message listener (userbot: outgoing only).

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) *Registry

func (*Registry) AddPrefix

func (r *Registry) AddPrefix(prefix string)

AddPrefix adds a prefix without removing existing ones.

func (*Registry) ExecuteCommand

func (r *Registry) ExecuteCommand(ctx context.Context, msg *interfaces.MessageEvent, name string, args []string) error

func (*Registry) Get

func (r *Registry) Get(name string) (*interfaces.Command, bool)

func (*Registry) GetAll

func (r *Registry) GetAll() map[string]*interfaces.Command

func (*Registry) GetByPlugin

func (r *Registry) GetByPlugin(plugin string) map[string]*interfaces.Command

func (*Registry) GetPrefix

func (r *Registry) GetPrefix() string

func (*Registry) GetPrefixes

func (r *Registry) GetPrefixes() []string

func (*Registry) IsCommand

func (r *Registry) IsCommand(text string) bool

IsCommand checks if text starts with any registered prefix.

func (*Registry) ParseCommand

func (r *Registry) ParseCommand(text string) (name string, args []string, ok bool)

ParseCommand parses a command from text, trying all registered prefixes. Returns the first match across all prefixes.

func (*Registry) Register

func (r *Registry) Register(cmd *interfaces.Command) error

func (*Registry) RemovePrefix

func (r *Registry) RemovePrefix(prefix string) bool

RemovePrefix removes a prefix (keeps at least one).

func (*Registry) SetOwnerID

func (r *Registry) SetOwnerID(id int64)

SetOwnerID updates the owner ID after initial resolution.

func (*Registry) SetPrefix

func (r *Registry) SetPrefix(prefix string)

func (*Registry) SetPrefixes

func (r *Registry) SetPrefixes(prefixes []string)

SetPrefixes replaces all prefixes.

func (*Registry) Unregister

func (r *Registry) Unregister(name string)

func (*Registry) UnregisterPlugin

func (r *Registry) UnregisterPlugin(plugin string)

func (*Registry) Use

func (r *Registry) Use(mw interfaces.Middleware)

Jump to

Keyboard shortcuts

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