Documentation
¶
Index ¶
Constants ¶
const BaseAPI = "https://slack.com/api/"
the base URL for the Slack web API
const MaxMessageSize = 1 << 24
The maximum RTM message size we are willing to consider. Although with general WebSockets this is effectively unlimited, Slack seems to cap messages around 16 MB.
const RtmStart = "rtm.start"
the RTM start method
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is the basic type for defining a simple chat bot.
func NewBot ¶
NewBot creates a new bot that connects to Slack with the given bot token. It will connect automatically and start processing responses in a goroutine.
func (*Bot) ClearResponses ¶
func (b *Bot) ClearResponses()
ClearResponses can be used to delete all of the rules that a bot knows about.
func (*Bot) RespondWith ¶
RespondWith responds to the given regular expression, if it matches anywhere in the string, by executing the given function to construct a response. The exec arguments are the user id and the array of the regular expression groups.
type Channel ¶
type Channel struct { ID string `json:"id"` Name string `json:"name"` IsChannel bool `json:"is_channel"` Created int64 `json:"created"` Creator string `json:"creator"` IsArchived bool `json:"is_archived"` IsGeneral bool `json:"is_general"` Members []string `json:"members"` Topic *SetValue `json:"topic"` Purpose *SetValue `json:"purpose"` IsMember bool `json:"is_member"` LastRead string `json:"last_read"` Latest *Message `json:"latest"` UnreadCount int64 `json:"unread_count"` }
Channel is the Slack API's channel response object.
type Message ¶
type Message map[string]interface{}
Message is a basic map that is used for JSON messages with the Slack APIs.
type Rtm ¶
type Rtm struct {
// contains filtered or unexported fields
}
Rtm is a structure that holds state for a real-time messaging WebSocket connection
type RtmStartResponse ¶
type RtmStartResponse struct { OK bool `json:"ok"` Err interface{} `json:"error"` URL string `json:"url"` Self *User `json:"self"` Team *Team `json:"team"` Users []User `json:"users"` Channels []Channel `json:"channels"` Groups []Group `json:"groups"` IMs []IM `json:"ims"` Bots []BotInfo `json:"bots"` }
RtmStartResponse is the JSON response from the rtm.start method.
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
Rule is a basic type representing bot a bot response rule.
type SetValue ¶
type SetValue struct { Value string `json:"value"` Creator string `json:"creator"` LastSet int64 `json:"last_set"` }
SetValue is a type used by Slack to represent a string value that has a creater and a set date, e.g., the topic.
type Slack ¶
type Slack struct {
// contains filtered or unexported fields
}
Slack can be used to send API calls to the Slack API, and also maintains an RTM (real-time messaging) connection.
func Connect ¶
Connect uses the given token to create a Slack API object, and starts up a RTM connection.
type Team ¶
type Team struct { ID string `json:"id"` Name string `json:"name"` EmailDomain string `json:"email_domain"` Domain string `json:"domain"` MsgEditWindowMins int64 `json:"msg_edit_window_mins"` OverStorageLimit bool `json:"over_storage_limit"` Prefs map[string]interface{} `json:"prefs"` }
Team is the Slack API's team response object.
type User ¶
type User struct { ID string `json:"id"` Name string `json:"name"` Deleted bool `json:"deleted"` Color string `json:"color"` Profile map[string]interface{} `json:"profile"` IsAdmin bool `json:"is_admin"` IsOwner bool `json:"is_owner"` IsPrimaryOwner bool `json:"is_primary_owner"` IsRestricted bool `json:"is_restricted"` IsUltraRestricted bool `json:"is_ultra_restricted"` Has2fa bool `json:"has_2fa"` HasFiles bool `json:"has_files"` }
User is the Slack API's user response object.