bot

package
v0.0.0-...-dafb618 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateLayout       = "01/02/2006"
	TimeLayout       = "03:04PM"
	DateTimeLayout   = DateLayout + " " + TimeLayout
	DateAtTimeLayout = DateLayout + " at " + TimeLayout
)

date and time layouts

View Source
const DatamuseAPIEndpoint = "https://api.datamuse.com"

DatamuseAPIEndpoint for the datamuse api

View Source
const TenorAPIEndpoint = "https://api.tenor.com/"

TenorAPIEndpoint for the gif api

View Source
const TriviaAPIEndpoint = "https://opentdb.com/api.php"

endpoint for the trivia api

Variables

This section is empty.

Functions

func NewAliasCommand

func NewAliasCommand(store db.Store, w io.Writer, invalidate func()) cli.Command

NewAliasCommand returns a cli.Command that manages !alias

func NewCandidateCommand

func NewCandidateCommand(store db.Store, w io.Writer) cli.Command

NewCandidateCommand returns a cli.Command that manages !candidate

func NewDefineCommand

func NewDefineCommand(endpoint string, w io.Writer) cli.Command

NewDefineCommand returns a cli.Command that manages !gif

func NewEchoCommand

func NewEchoCommand(w io.Writer) cli.Command

NewEchoCommand returns a cli.Command that manages !echo

func NewGIFCommand

func NewGIFCommand(endpoint, key string, w io.Writer) cli.Command

NewGIFCommand returns a cli.Command that manages !gif

func NewGlossaryCommand

func NewGlossaryCommand(store db.Store, w io.Writer) cli.Command

NewGlossaryCommand returns a cli.Command that manages !glossary

func NewHelpCommand

func NewHelpCommand(w io.Writer) cli.Command

NewHelpCommand returns a cli.Command that manages !help

func NewInterviewCommand

func NewInterviewCommand(store db.Store, w io.Writer) cli.Command

NewInterviewCommand returns a cli.Command that manages !interview

func NewKarmaCommand

func NewKarmaCommand(store db.Store, w io.Writer) cli.Command

NewKarmaCommand returns a cli.Command that manages !karma

func NewRedoCommand

func NewRedoCommand(trigger func() error) cli.Command

NewRedoCommand returns a cli.Command that manages !redo.

func NewTriviaCommand

func NewTriviaCommand(store db.Store, endpoint string, w io.Writer) cli.Command

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

type Behavior func(e slack.RTMEvent) error

Behavior executes some functionality when a RTMEvent occurs.

func NewKarmaTrackingBehavior

func NewKarmaTrackingBehavior(store db.Store) Behavior

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.

func (Behaviors) Run

func (behaviors Behaviors) Run(e slack.RTMEvent) error

Run will execute each behavior against the event. Errors returned from each behavior are aggregated into a single error.

type DatamuseResponse

type DatamuseResponse struct {
	Definitions []string `json:"defs"`
	Word        string   `json:"word"`
}

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

Jump to

Keyboard shortcuts

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