Documentation
¶
Index ¶
- func InitLogger(cfg config.Logger)
- func RegisterPlugin(plugin Plugin)
- type BaseCommand
- type Bot
- type Category
- type Command
- type Commands
- func (c *Commands) AddCommand(commands ...Command)
- func (c *Commands) Count() int
- func (c *Commands) GetCommandNames() []string
- func (c *Commands) GetHelp() []Help
- func (c *Commands) Merge(commands Commands)
- func (c *Commands) Run(message msg.Message) bool
- func (c *Commands) RunWithName(message msg.Message) (bool, string)
- type Conditional
- type Help
- type HelpProvider
- type Plugin
- type Runnable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
InitLogger provides logger instance for the given config
func RegisterPlugin ¶ added in v2.3.9
func RegisterPlugin(plugin Plugin)
RegisterPlugin registers a new plugin, also in init() time
Types ¶
type BaseCommand ¶
type BaseCommand struct {
client.SlackClient
}
BaseCommand is base struct which is handy for all commands, as a direct Slack communication is possible
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is the main object which is holding the connection to Slack and all possible commands it also registers the listener and handles topics like authentication and logging
func NewBot ¶
NewBot created main Bot struct which holds the slack connection and dispatch messages to commands
func (*Bot) HandleMessage ¶
func (b *Bot) HandleMessage(message *slack.MessageEvent)
HandleMessage is the entry point for incoming slack messages: - checks if the message is relevant (direct message to bot or mentioned via @bot) - is the user allowed to interact with the bot? - find the matching command and execute it
func (*Bot) ProcessMessage ¶ added in v2.2.4
ProcessMessage process the incoming message and respond appropriately
func (*Bot) Run ¶ added in v2.2.3
func (b *Bot) Run(ctx *util.ServerContext)
Run is blocking method to handle new incoming events...from different sources
type Category ¶
Category of Help entries. -> Groups command in help command by "Jenkins", "Pull request" etc
type Command ¶
Command is the main command struct which needs to provide the matcher and the actual executed action
type Commands ¶
type Commands struct {
// contains filtered or unexported fields
}
Commands is a wrapper of a list of commands. Only the first matched command will be executed
func (*Commands) AddCommand ¶
AddCommand registers a command to the command list
func (*Commands) GetCommandNames ¶ added in v2.2.10
type Conditional ¶
type Conditional interface {
IsEnabled() bool
}
Conditional checks if the command should be activated. E.g. is dependencies are not present or it's disabled in the config
type Help ¶
type Help struct { Command string Description string HelpURL string Category Category Examples []string }
Help command can provide help objects which are searchable by keywords
func (*Help) GetKeywords ¶
GetKeywords crates a string slice of help keywords -> used by fuzzy search
type HelpProvider ¶
type HelpProvider interface { // GetHelp each command should provide information, like a description or examples GetHelp() []Help }
HelpProvider can be provided by a command to add information within "help" command
type Plugin ¶ added in v2.3.9
type Plugin struct {
Init func(bot *Bot, slackClient client.SlackClient) Commands
}
Plugin is a extended command which can be registered to the bot at compile time
type Runnable ¶ added in v2.2.10
type Runnable interface {
RunAsync(ctx *util.ServerContext)
}
Runnable indicates that the command executes a go function