Documentation ¶
Index ¶
- Constants
- type Bot
- func (b *Bot) AddSchedule(schedule *Schedule) string
- func (b *Bot) DeleteSchedule(name string)
- func (b *Bot) GetAllowedUser(slackUser string) User
- func (b *Bot) GetTasksForChannel(channel string) []*CronTask
- func (b *Bot) GetUserFile() string
- func (b *Bot) Init(config *config.Config) (err error)
- func (b *Bot) InitTasks()
- func (b *Bot) IsValidSchedule(spec string) bool
- func (b *Bot) NewSchedule(project string, time string, command string, channel string, user User) *Schedule
- func (b *Bot) ReloadSlackChannels()
- func (b *Bot) ReloadSlackUsers()
- func (b *Bot) ReloadUserFile()
- type Command
- type Commands
- type CronTask
- type Help
- type Schedule
- type User
Constants ¶
const ( // NotRegistered is the default reply when rights don't match NotRegistered = "I'm sorry, but you are not allowed to use this command." // UserRightUser is the default user right for any user UserRightUser = "user" // UserRightAdmin is the user right for admins who can use some hidden features UserRightAdmin = "admin" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct { Crons map[string]*CronTask AllowedUsers []User // contains filtered or unexported fields }
Bot is a wrapper for the authentification, slack client, all commands, running crons and users allowed to schedule crons
func NewBot ¶
NewBot created main bot struct which holds the slack connection and dispatch messages to commands
func (*Bot) AddSchedule ¶
AddSchedule is used to add a new schedule via a cron
func (*Bot) DeleteSchedule ¶
DeleteSchedule removes a schedule from the active crons and from the schedule list
func (*Bot) GetAllowedUser ¶
GetAllowedUser returns all users which are allowed to handle schedules
func (*Bot) GetTasksForChannel ¶
GetTasksForChannel is returning all tasks which are active in the given channel
func (*Bot) GetUserFile ¶
GetUserFile returns the path to the user file where the allowed users are stored
func (*Bot) IsValidSchedule ¶
IsValidSchedule checks if a schedule can be parsed
func (*Bot) NewSchedule ¶
func (b *Bot) NewSchedule(project string, time string, command string, channel string, user User) *Schedule
NewSchedule holds all information for creating a new schedule
func (*Bot) ReloadSlackChannels ¶
func (b *Bot) ReloadSlackChannels()
ReloadSlackChannels handles updating client.Channels, so new channels will be added within an hour
func (*Bot) ReloadSlackUsers ¶
func (b *Bot) ReloadSlackUsers()
ReloadSlackUsers handles updating the client.Users map, so new slack users will be added within 24 hours
func (*Bot) ReloadUserFile ¶
func (b *Bot) ReloadUserFile()
ReloadUserFile handles updating the user file every 10 seconds
type Command ¶
type Command interface { // return true in case command did a response Execute(ctx context.Context, b *Bot, eventText string, event *slack.MessageEvent, user User) bool // return true in case command can be scheduled and passed a basic check IsValid(b *Bot, command string) bool // each command has a name GetName() string // information on how to use the command with examples GetHelp() []Help }
Command is the main command struct which needs to provide the actual executed action, validation, a name and a help for the user
type Commands ¶
type Commands struct {
Commands []Command
}
Commands is a wrapper of a list of commands. Only the first matched command will be executed