Documentation ¶
Index ¶
- func FormatParamString(pr string) string
- func ParseParams(content string) []string
- type Bot
- type Command
- func (c *Command) AddParam(param *CommandParameter)
- func (c *Command) AddParameter(name string, description string, required bool)
- func (c *Command) GetParam(content string, name string) (pr string, err error)
- func (c *Command) GetRequiredParam(content string, name string) (pr string, err error)
- func (c *Command) HelpString() string
- func (c *Command) HelpUsage() string
- func (c *Command) SignatureWithPrefix() string
- type CommandHandler
- func (ch *CommandHandler) AddCommand(cmd *Command)
- func (ch *CommandHandler) AddMessageTrigger(s string, r string)
- func (ch *CommandHandler) FindCommand(content string, withPrefix bool) (c *Command, err error)
- func (ch *CommandHandler) MaybeHandleCodeBlock(s *dgo.Session, m *dgo.MessageCreate) (res string, err error)
- func (ch *CommandHandler) MaybeHandleMessageTrigger(s *dgo.Session, m *dgo.MessageCreate) (r string, err error)
- type CommandParameter
- type Conversation
- type MessageContext
- type Trigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatParamString ¶
FormatParamString removes certain characters like "" from the param response string.
func ParseParams ¶
ParseParams gets a slice of arguments in a string.
Goes through each rune and determines what to do with it. If the rune is in Quotes "something something", it will return the whole string in quotes.
Types ¶
type Bot ¶
type Bot struct { Session *dgo.Session Prefix string CmdHandler *CommandHandler MessageCreate chan *dgo.MessageCreate // contains filtered or unexported fields }
Bot is a discord bot, yo!
type Command ¶
type Command struct { Signature string Description string Prefix string Aliases []string Parameters []*CommandParameter Handler newCommandHandlerFunc }
Command : this is a command...
func NewCommand ¶
NewCommand creates a new command and returns it!
func (*Command) AddParam ¶
func (c *Command) AddParam(param *CommandParameter)
AddParam adds a param to a command.
func (*Command) AddParameter ¶
AddParameter adds a new parameter to the command. Parameters should be added in order.
func (*Command) GetParam ¶
GetParam : parses the params and gets the correct value for the param with the name given. TODO: change this so it can be used like:
p := c.GetParam(content, "paramName") if !p { did not find the param. }
func (*Command) GetRequiredParam ¶
GetRequiredParam TODO actually not really sure where I was going with this. Something about sending a response back to the user..
func (*Command) HelpString ¶
HelpString returns a string of how this Command is used.
func (*Command) SignatureWithPrefix ¶
SignatureWithPrefix returns a concatenated string with prefix and signature
type CommandHandler ¶
type CommandHandler struct { Commands []*Command Prefix string Triggers []*Trigger Conversations []*Conversation }
CommandHandler : Holds a list of commands and specifies the Bot prefix. TODO: use maps for some stuff...
func NewCommandHandler ¶
func NewCommandHandler(Prefix string) *CommandHandler
NewCommandHandler creates a new CommandHandler with Prefix and sets up the default commands.
default commands: help
TODO: Move this away from here!
func (*CommandHandler) AddCommand ¶
func (ch *CommandHandler) AddCommand(cmd *Command)
AddCommand adds a command to the command handler.
func (*CommandHandler) AddMessageTrigger ¶
func (ch *CommandHandler) AddMessageTrigger(s string, r string)
AddMessageTrigger adds a new Trigger to the Triggers slice on CommandHandler
func (*CommandHandler) FindCommand ¶
func (ch *CommandHandler) FindCommand(content string, withPrefix bool) (c *Command, err error)
FindCommand finds a command (if it exists) within the commandHandler.
func (*CommandHandler) MaybeHandleCodeBlock ¶
func (ch *CommandHandler) MaybeHandleCodeBlock(s *dgo.Session, m *dgo.MessageCreate) (res string, err error)
MaybeHandleCodeBlock takes a string and figures out if it's in a codeblock format. TODO: figure out what language is being passed in. ```js <- js should be the language. TODO: Have a separate Handler for each language that is supported. TODO: Can an API be generalized for creating Maybe handlers? TODO: Create a handler for a specific language. Do something!!!!
func (*CommandHandler) MaybeHandleMessageTrigger ¶
func (ch *CommandHandler) MaybeHandleMessageTrigger(s *dgo.Session, m *dgo.MessageCreate) (r string, err error)
MaybeHandleMessageTrigger looks for a pattern in any message and responds
type CommandParameter ¶
CommandParameter : Specifies the name, position and what this parameter does.
type Conversation ¶
type Conversation struct {
UserID string
}
Conversation between the bot and a user..
type MessageContext ¶
type MessageContext struct { Session *dgo.Session Bot *Bot Message *dgo.MessageCreate Command *Command }
MessageContext is usually just for when Command handlers are being run, but this could be used for different things.
func (*MessageContext) GetVal ¶
func (c *MessageContext) GetVal() (b *Bot, m *dgo.MessageCreate, cmd *Command, s *dgo.Session)
GetVal gets the values from MessageContext... this makes it easier to extract the info when all are needed.