commands

package
v0.0.0-...-f7f6175 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ActiveCommands = make(map[string]*Command)
	WaitList       = make(map[string]time.Time)
)

ActiveCommands the current avaliable commands

Functions

func GetCommandID

func GetCommandID(text string) string

GetCommandID slicing the message and searching for aliases

func HavePermitions

func HavePermitions(command *Command, msg whatsapp.TextMessage) (logs []string)

HavePermitions Check if the participant have the permitions to use some command

func ParseCommand

func ParseCommand(wac *whatsapp.Conn, msg whatsapp.TextMessage)

ParseCommand analyze the command FIXME: add error definitions

Types

type Command

type Command struct {
	ID          string
	Name        string
	Aliases     []string
	Subcommands []string
	Args        []string
	Help        string

	RootOnly bool

	Cooldown time.Duration

	Exec func(*whatsapp.Conn, whatsapp.TextMessage, map[string]string) error
}

Command all command data

func New

func New(name string, f func(*whatsapp.Conn, whatsapp.TextMessage, map[string]string) error) *Command

New creates a new command

func (*Command) Add

func (c *Command) Add()

Add activate command

func (*Command) OnlyRoot

func (c *Command) OnlyRoot() *Command

OnlyRoot only the bot number can use the command

func (*Command) SetAliases

func (c *Command) SetAliases(aliases ...string) *Command

SetAliases to the command

func (*Command) SetArgs

func (c *Command) SetArgs(args ...string) *Command

SetArgs set the command args

func (*Command) SetCooldown

func (c *Command) SetCooldown(seconds time.Duration) *Command

SetCooldown to re use the command

func (*Command) SetHelp

func (c *Command) SetHelp(format string, args ...interface{}) *Command

SetHelp to the command

func (*Command) SetSubcommands

func (c *Command) SetSubcommands(commands ...string) *Command

SetSubcommands set a sub command

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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