handlers

package
v0.0.0-...-382b95a Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BotStack

func BotStack(prompts []string) bot.Handler

BotStack responds to messages with information about the bot and where it runs when Message.TrimmedText contains one of prompts.

func BotVersion

func BotVersion(prompt, version string) bot.Handler

BotVersion responds to messages with the bot's version when Message.TrimmedText matches prompt.

func CoinFlip

func CoinFlip(prompts []string) bot.Handler

CoinFlip responds to messages with "heads" or "tails" when Message.TrimmedText matches one of prompts.

func Join

func Join(welcomeChannels []Channel) bot.JoinHandler

Join direct messages new users with a message about the Slack team and some recommended channels.

func LinkToGoDoc

func LinkToGoDoc(matchPrefix, urlPrefix string) bot.Handler

LinkToGoDoc responds with to messages with matchPrefix replaced by urlPrefix.

func NewbieResources

func NewbieResources(prefix string) bot.Handler

NewbieResources responds with some beginner resources when Message.TrimmedText has prefix.

If Message.TrimmedText also contains "pvt" the response will be sent as a direct message.

func ProcessLinear

func ProcessLinear(hs ...bot.Handler) bot.Handler

ProcessLinear calls handlers in order.

func ReactWhenContains

func ReactWhenContains(s string, reactions ...string) bot.Handler

ReactWhenContains adds reactions to messages that contain s.

func ReactWhenContainsRand

func ReactWhenContainsRand(s string, reactions ...string) bot.Handler

ReactWhenContainsRand randomly calls ReactWhenContains.

Currently probability is 1/150.

func ReactWhenHasPrefix

func ReactWhenHasPrefix(s string, reactions ...string) bot.Handler

ReactWhenHasPrefix addes reactions to messages when Message.TrimmedText has prefix s.

func RecommendedChannels

func RecommendedChannels(prompt string, channels []Channel) bot.Handler

RecommendedChannels responds to messages a formatted list of channels when Message.TrimmedText matches prompt.

func RespondTo

func RespondTo(prompts []string, response string) bot.Handler

RespondTo responds to messages when Message.TrimmedText is in prompts.

func RespondWhenContains

func RespondWhenContains(s string, response string) bot.Handler

RespondWhenContains responds to any message when that contains s.

func SearchForLibrary

func SearchForLibrary(prefix string) bot.Handler

SearchForLibrary responds to messages with suggested places to look for a library when Message.TrimmedText has prefix.

func Songs

func Songs() bot.Handler

Songs inspects the message for Spotify, Soundcloud, Tidal links.

func SuggestPlayground

func SuggestPlayground(h *http.Client, s *slack.Client, l bot.Logger, minLines int) bot.Handler

SuggestPlayground uploads messages/files to the playground when they have at least minLines or has files that are of type "go" or "text".

After uploading, a link will be posted to the channel and a suggestion to use the playground is sent directly to the user.

func WhenDirectedToBot

func WhenDirectedToBot(h bot.Handler) bot.Handler

WhenDirectedToBot calls h when Message.DirectedToBot is true.

func XKCD

func XKCD(prefix string, aliases map[string]int, logf bot.Logger) bot.Handler

XKCD responds with XKCD comics when Message.TrimmedText has prefix.

After the prefix either a comic number or alias can be provided.

Types

type Channel

type Channel struct {
	Name        string
	Description string
}

Channel describes a Slack channel.

Jump to

Keyboard shortcuts

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