Documentation
¶
Index ¶
- type Parser
- type Registry
- func (r *Registry) AddPrefix(prefix string)
- 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) 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) SetOwnerID(id int64)
- func (r *Registry) SetPrefix(prefix string)
- func (r *Registry) SetPrefixes(prefixes []string)
- func (r *Registry) Unregister(name string)
- func (r *Registry) UnregisterPlugin(plugin string)
- func (r *Registry) Use(mw interfaces.Middleware)
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.
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) 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) 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) SetOwnerID ¶
SetOwnerID updates the owner ID after initial resolution.
func (*Registry) SetPrefixes ¶
SetPrefixes replaces all prefixes.
func (*Registry) Unregister ¶
func (*Registry) UnregisterPlugin ¶
func (*Registry) Use ¶
func (r *Registry) Use(mw interfaces.Middleware)