Documentation ¶
Index ¶
- Constants
- func NewAliasCommand(store db.Store, w io.Writer, invalidate func()) cli.Command
- func NewCandidateCommand(store db.Store, w io.Writer) cli.Command
- func NewDefineCommand(endpoint string, w io.Writer) cli.Command
- func NewEchoCommand(w io.Writer) cli.Command
- func NewGIFCommand(endpoint, key string, w io.Writer) cli.Command
- func NewGlossaryCommand(store db.Store, w io.Writer) cli.Command
- func NewHelpCommand(w io.Writer) cli.Command
- func NewInterviewCommand(store db.Store, w io.Writer) cli.Command
- func NewKarmaCommand(store db.Store, w io.Writer) cli.Command
- func NewRedoCommand(trigger func() error) cli.Command
- func NewTriviaCommand(store db.Store, endpoint string, w io.Writer) cli.Command
- func NewUndoCommand(appClient, botClient utils.SlackClient, channelID, botID string) cli.Command
- type AliasBehavior
- type Behavior
- type Behaviors
- type DatamuseResponse
- type Gif
- type RedoBehavior
- type TenorSearchResponse
- type TriviaQuestion
- type TriviaResponse
Constants ¶
const ( DateLayout = "01/02/2006" TimeLayout = "03:04PM" DateTimeLayout = DateLayout + " " + TimeLayout DateAtTimeLayout = DateLayout + " at " + TimeLayout )
date and time layouts
const DatamuseAPIEndpoint = "https://api.datamuse.com"
DatamuseAPIEndpoint for the datamuse api
const TenorAPIEndpoint = "https://api.tenor.com/"
TenorAPIEndpoint for the gif api
const TriviaAPIEndpoint = "https://opentdb.com/api.php"
endpoint for the trivia api
Variables ¶
This section is empty.
Functions ¶
func NewAliasCommand ¶
NewAliasCommand returns a cli.Command that manages !alias
func NewCandidateCommand ¶
NewCandidateCommand returns a cli.Command that manages !candidate
func NewDefineCommand ¶
NewDefineCommand returns a cli.Command that manages !gif
func NewEchoCommand ¶
NewEchoCommand returns a cli.Command that manages !echo
func NewGIFCommand ¶
NewGIFCommand returns a cli.Command that manages !gif
func NewGlossaryCommand ¶
NewGlossaryCommand returns a cli.Command that manages !glossary
func NewHelpCommand ¶
NewHelpCommand returns a cli.Command that manages !help
func NewInterviewCommand ¶
NewInterviewCommand returns a cli.Command that manages !interview
func NewKarmaCommand ¶
NewKarmaCommand returns a cli.Command that manages !karma
func NewRedoCommand ¶
NewRedoCommand returns a cli.Command that manages !redo.
func NewTriviaCommand ¶
NewTriviaCommand returns a cli.Command that manages !trivia
func NewUndoCommand ¶
func NewUndoCommand(appClient, botClient utils.SlackClient, channelID, botID string) cli.Command
NewUndoCommand returns a cli.Command that manages !undo. Due to Slack's permission model, only clients which have "bot" authentication are allowed to delete messages sent by the bot. However, only clients which have "app" authentication are allowed to get chat history for Channels, Groups, and IMs. Because of this, we must pass in a SlackClient authenticated for each.
Types ¶
type AliasBehavior ¶
type AliasBehavior struct {
// contains filtered or unexported fields
}
AliasBehavior will apply alias transformations to slack message events
func NewAliasBehavior ¶
func NewAliasBehavior(store db.Store) *AliasBehavior
NewAliasBehavior will create a new instance of an AliasBehavior object
func (*AliasBehavior) Behavior ¶
func (a *AliasBehavior) Behavior() Behavior
Behavior will return the AliasBehavior's Behavior function. This function will apply alias transformations to slack message events. Aliases are loaded from the AliasBehavior's store, and then cached for performance. The Invalidate() function should be called to invalid the AliasBehavior's cache.
func (*AliasBehavior) Invalidate ¶
func (a *AliasBehavior) Invalidate()
Invalidate will cause the AliasBehavior to invalidate its cache
type Behavior ¶
Behavior executes some functionality when a RTMEvent occurs.
func NewKarmaTrackingBehavior ¶
NewKarmaTrackingBehavior returns a behavior that updates karma in the provided store. Karma updates are triggered by the presence of '++', '--', '+-', '-+' at the end of a message.
func NewNormalizeTextBehavior ¶
func NewNormalizeTextBehavior() Behavior
NewNormalizeTextBehavior returns a behavior that normalizes the text in slack message events
type Behaviors ¶
type Behaviors []Behavior
Behaviors adds functionality to a slice of Behavior objects.
type DatamuseResponse ¶
DatamuseResponse is the response type for a Tenor API search
type Gif ¶
type Gif struct {
URL string `json:"itemurl"`
}
Gif holds information about a Gif from Tenor
type RedoBehavior ¶
type RedoBehavior struct {
// contains filtered or unexported fields
}
RedoBehavior is used to record and trigger the last slack.MessageEvent for a Slack channel. Events are recorded using the Record() function. Events are triggered using the Trigger() function.
func NewRedoBehavior ¶
func NewRedoBehavior(c chan slack.RTMEvent) *RedoBehavior
NewRedoBehavior will create a new instance of a RedoBehavior.
func (*RedoBehavior) Record ¶
func (r *RedoBehavior) Record(channelID string, e slack.RTMEvent) error
Record will record e as the last event for the specified channel. Events cannot be a *slack.MessageEvent with a message that starts with "!redo".
func (*RedoBehavior) Trigger ¶
func (r *RedoBehavior) Trigger(channelID string) error
Trigger will send the last event of the specified channel to the RedoBehavior's RTMEvent channel. An error will be thrown if no event has been recorded for the specified channel.
type TenorSearchResponse ¶
type TenorSearchResponse struct {
Gifs []Gif `json:"results"`
}
TenorSearchResponse is the response type for a Tenor API search
type TriviaQuestion ¶
type TriviaQuestion struct { Category string `json:"category"` Question string `json:"question"` CorrectAnswer string `json:"correct_answer"` IncorrectAnswers []string `json:"incorrect_answers"` }
TriviaQuestion holds information about a single trivia question
type TriviaResponse ¶
type TriviaResponse struct {
Questions []TriviaQuestion `json:"results"`
}
TriviaResponse is the response type for a trivia api search
Source Files ¶
- alias_behavior.go
- alias_command.go
- behavior.go
- candidate_command.go
- define_command.go
- echo_command.go
- gif_command.go
- glossary_command.go
- help_command.go
- interview_command.go
- karma_command.go
- karma_tracking_behavior.go
- normalize_text_behavior.go
- redo_behavior.go
- redo_command.go
- trivia_command.go
- undo_command.go
- utils.go