modulepackage
0.0.0-20180413082600-f1a7282d17d6
Repository: https://github.com/adampointer/go-slackbot.git
Documentation: pkg.go.dev
# README
go-slackbot - Build Slackbots in Go
The go-slackbot project hopes to ease development of Slack bots by adding helpful methods and a mux-router style interface to the github.com/essentialkaos/slack package.
Incoming Slack RTM events are mapped to a handler in the following form:
bot.Hear("(?i)how are you(.*)").MessageHandler(HowAreYouHandler)
In addition to several useful functions in the utils.go file, the slackbot.Bot struct provides handy Reply and ReplyWithAttachments methods:
func HowAreYouHandler(ctx context.Context, bot *slackbot.Bot, evt *slack.MessageEvent) {
bot.Reply(evt, "A bit tired. You get it? A bit?", slackbot.WithTyping)
}
func HowAreYouAttachmentsHandler(ctx context.Context, bot *slackbot.Bot, evt *slack.MessageEvent) {
txt := "Beep Beep Boop is a ridiculously simple hosting platform for your Slackbots."
attachment := slack.Attachment{
Pretext: "We bring bots to life. :sunglasses: :thumbsup:",
Title: "Host, deploy and share your bot in seconds.",
TitleLink: "https:beepboophq.com/",
Text: txt,
Fallback: txt,
ImageURL: "https:storage.googleapis.com/beepboophq/_assets/bot-1.22f6fb.png",
Color: "#7CD197",
}
attachments := []slack.Attachment{attachment}
bot.ReplyWithAttachments(evt, attachments, slackbot.WithTyping)
}
But wait, there's more! Well, until there's more, the slackbot package exposes github.com/essentialkaos/slack RTM and Client objects enabling a consumer to interact with the lower level package directly:
func HowAreYouHandler(ctx context.Context, bot *slackbot.Bot, evt *slack.MessageEvent) {
bot.RTM.NewOutgoingMessage("Hello", "#random")
}
If you want to kick the tires, we would love feedback. Check out these two examples:
# Packages
No description provided by the author
# Functions
AddBotToContext sets the bot reference in context and returns the newly derived context.
AddMessageToContext sets the Slack message event reference in context and returns the newly derived context.
No description provided by the author
IsDirectMention returns true is message is a Direct Mention that mentions a specific user.
IsDirectMessage returns true if this message is in a direct message conversation.
IsMention returns true the message contains a mention.
IsMentioned returns true if this message contains a mention of a specific user.
No description provided by the author
New constructs a new Bot using the slackToken to authorize against the Slack service.
StripDirectMention removes a leading mention (aka direct mention) from a message string.
WhoMentioned returns a list of userIDs mentioned in the message.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
RouteMatch stores information about a matched route.
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author