roxy

package module
v0.0.0-...-6bd6096 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Commands          types.Embed[*Command]
	GlobalMiddlewares types.Embed[context.MiddlewareFunc]
	Middlewares       types.Embed[context.MiddlewareFunc]
	Categories        types.Embed[string]
)

Functions

func ParseCommandArguments

func ParseCommandArguments(argsList []string, argDefinitions map[string]Argument) (map[string]any, error)

Types

type App

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

func NewRoxyBase

func NewRoxyBase(options *options.Options) (*App, error)

func (*App) AddNewCategory

func (app *App) AddNewCategory(category string)

func (*App) AddNewCommand

func (app *App) AddNewCommand(command Command)

func (*App) AddNewMiddleware

func (app *App) AddNewMiddleware(middleware context.MiddlewareFunc)

func (*App) Client

func (app *App) Client() *whatsmeow.Client

func (*App) ClientJID

func (app *App) ClientJID() waTypes.JID

func (*App) FindMessageByID

func (app *App) FindMessageByID(jid waTypes.JID, id string) *events.Message

func (*App) GetAllChats

func (app *App) GetAllChats() []*events.Message

func (*App) GetChatInJID

func (app *App) GetChatInJID(jid waTypes.JID) []*events.Message

func (*App) GetStatusMessages

func (app *App) GetStatusMessages() []*events.Message

func (*App) HandleEvents

func (app *App) HandleEvents(event any)

func (*App) InitializeClient

func (app *App) InitializeClient() error

func (*App) SendMessage

func (app *App) SendMessage(to waTypes.JID, message *waProto.Message, extra ...whatsmeow.SendRequestExtra) (whatsmeow.SendResponse, error)

func (*App) Shutdown

func (app *App) Shutdown()

func (*App) UpsertMessages

func (app *App) UpsertMessages(jid waTypes.JID, message []*events.Message)

type Argument

type Argument struct {
	Name         string
	Type         ArgumentType
	Description  string
	Required     bool
	DefaultValue any
	IsCatchAll   bool
}

type ArgumentOptions

type ArgumentOptions struct {
	DefaultValue any
	IsCatchAll   bool
}

type ArgumentType

type ArgumentType int
const (
	ArgumentInt ArgumentType = iota
	ArgumentFloat
	ArgumentString
	ArgumentBool
)

type Command

type Command struct {
	Name        string
	Aliases     []string
	Description string

	Category string
	Cache    bool

	HideFromHelp bool
	GroupOnly    bool
	PrivateOnly  bool

	OnlyAdminGroup   bool
	OnlyIfBotAdmin   bool
	AdditionalValues map[string]any

	SubCommands map[string]*Command

	Arguments  map[string]Argument
	RunFunc    context.RunFunc
	Middleware context.MiddlewareFunc
}

func NewCommand

func NewCommand(name string) *Command

func (*Command) AddArgument

func (c *Command) AddArgument(name, description string, argType ArgumentType, required bool, options ...ArgumentOptions)

func (*Command) AddSubCommands

func (c *Command) AddSubCommands(cmd *Command)

func (*Command) SetAdditionalValues

func (c *Command) SetAdditionalValues(value map[string]any)

func (*Command) SetAliases

func (c *Command) SetAliases(values []string)

func (*Command) SetCategory

func (c *Command) SetCategory(value string)

func (*Command) SetDescription

func (c *Command) SetDescription(value string)

func (*Command) SetGroupOnly

func (c *Command) SetGroupOnly(value bool)

func (*Command) SetHideFromHelp

func (c *Command) SetHideFromHelp(value bool)

func (*Command) SetOnlyAdminGroup

func (c *Command) SetOnlyAdminGroup(value bool)

func (*Command) SetOnlyIfBotAdmin

func (c *Command) SetOnlyIfBotAdmin(value bool)

func (*Command) SetPrivateOnly

func (c *Command) SetPrivateOnly(value bool)

func (*Command) SetRunFunc

func (c *Command) SetRunFunc(fn context.RunFunc)

func (*Command) Use

func (c *Command) Use(fn context.MiddlewareFunc)

func (*Command) UseCache

func (c *Command) UseCache(value bool)

func (*Command) Validate

func (c *Command) Validate()

type Muxer

type Muxer struct {
	Options              *options.Options                             `json:"options,omitempty"`
	Log                  waLog.Logger                                 `json:"log,omitempty"`
	MessageTimeout       time.Duration                                `json:"message_timeout,omitempty"`
	Categories           *xsync.MapOf[string, string]                 `json:"categories,omitempty"`
	GlobalMiddlewares    *xsync.MapOf[string, context.MiddlewareFunc] `json:"global_middlewares,omitempty"`
	Middlewares          *xsync.MapOf[string, context.MiddlewareFunc] `json:"middlewares,omitempty"`
	Commands             *xsync.MapOf[string, *Command]               `json:"commands,omitempty"`
	CommandResponseCache *xsync.MapOf[string, *waProto.Message]       `json:"command_response_cache,omitempty"`
	QuestionState        *xsync.MapOf[string, *context.QuestionState] `json:"question_state,omitempty"`
	PollingState         *xsync.MapOf[string, *context.PollingState]  `json:"polling_state,omitempty"`
	GroupCache           *xsync.MapOf[string, []*waTypes.GroupInfo]   `json:"group_cache,omitempty"`
	Locals               *xsync.MapOf[string, string]                 `json:"locals,omitempty"`

	QuestionChan    chan *context.QuestionState                           `json:"question_chan,omitempty"`
	PollingChan     chan *context.PollingState                            `json:"polling_chan,omitempty"`
	SuggestionModel *fuzzy.Model                                          `json:"suggestion_model,omitempty"`
	CommandParser   func(str string) (prefix string, cmd string, ok bool) `json:"command_parser,omitempty"`

	types.AppMethods
}

func NewMuxer

func NewMuxer(log waLog.Logger, options *options.Options, appMethods types.AppMethods) *Muxer

func (*Muxer) AddCommand

func (muxer *Muxer) AddCommand(cmd *Command)

func (*Muxer) AddCommandParser

func (muxer *Muxer) AddCommandParser(context func(str string) (prefix string, cmd string, ok bool))

func (*Muxer) AddGlobalMiddleware

func (muxer *Muxer) AddGlobalMiddleware(middleware context.MiddlewareFunc)

func (*Muxer) AddMiddleware

func (muxer *Muxer) AddMiddleware(middleware context.MiddlewareFunc)

func (*Muxer) CacheAllGroup

func (muxer *Muxer) CacheAllGroup()

func (*Muxer) Clean

func (muxer *Muxer) Clean()

func (*Muxer) FindGroupByJid

func (muxer *Muxer) FindGroupByJid(groupJid waTypes.JID) (group *waTypes.GroupInfo, err error)

func (*Muxer) GenerateSuggestionModel

func (muxer *Muxer) GenerateSuggestionModel()

func (*Muxer) GetActiveCommand

func (muxer *Muxer) GetActiveCommand() []*Command

func (*Muxer) GetActiveGlobalMiddleware

func (muxer *Muxer) GetActiveGlobalMiddleware() []context.MiddlewareFunc

func (*Muxer) GetActiveMiddleware

func (muxer *Muxer) GetActiveMiddleware() []context.MiddlewareFunc

func (*Muxer) GetAllGroups

func (muxer *Muxer) GetAllGroups() (group []*waTypes.GroupInfo, err error)

func (*Muxer) IsClientGroupAdmin

func (muxer *Muxer) IsClientGroupAdmin(chat waTypes.JID) (bool, error)

func (*Muxer) IsGroupAdmin

func (muxer *Muxer) IsGroupAdmin(chat waTypes.JID, jid any) (bool, error)

func (*Muxer) RunCommand

func (muxer *Muxer) RunCommand(c *whatsmeow.Client, evt *events.Message)

func (*Muxer) SendEmojiMessage

func (muxer *Muxer) SendEmojiMessage(event *events.Message, emoji string)

func (*Muxer) SuggestCommand

func (muxer *Muxer) SuggestCommand(event *events.Message, prefix, command string)

func (*Muxer) UnCacheOneGroup

func (muxer *Muxer) UnCacheOneGroup(info *events.GroupInfo, joined *events.JoinedGroup)

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

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