Documentation ¶
Overview ¶
Package events implements handlers for Slack's Events API: see https://api.slack.com/apis/connections/events-api and https://api.slack.com/events?ref=apis&filter=Events.
Each event handler is required to return within 3 seconds, even if its response is an empty acknowledgement (an HTTP 200 status with no payload) which continues behind the scenes with further asynchronous processing. see https://api.slack.com/apis/connections/events-api#responding.
Index ¶
- func AppMentionHandler(l *zap.Logger, w http.ResponseWriter, body []byte, cb *Callback) any
- func ChannelCreatedHandler(l *zap.Logger, w http.ResponseWriter, body []byte, cb *Callback) any
- func ChannelGroupHandler(l *zap.Logger, w http.ResponseWriter, body []byte, cb *Callback) any
- func MessageHandler(l *zap.Logger, w http.ResponseWriter, body []byte, cb *Callback) any
- func ReactionHandler(l *zap.Logger, w http.ResponseWriter, body []byte, cb *Callback) any
- func URLVerificationHandler(l *zap.Logger, w http.ResponseWriter, body []byte, _ *Callback) any
- type AppMentionEvent
- type Authorization
- type Callback
- type ChannelCreatedEvent
- type ChannelGroupEvent
- type Event
- type Item
- type ReactionEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppMentionHandler ¶
func ChannelCreatedHandler ¶
func ChannelGroupHandler ¶
https://api.slack.com/events/channel_archive https://api.slack.com/events/channel_unarchive https://api.slack.com/events/group_archive https://api.slack.com/events/group_open https://api.slack.com/events/group_unarchive https://api.slack.com/events/member_joined_channel
func MessageHandler ¶
https://api.slack.com/events/message https://api.slack.com/events/message.channels https://api.slack.com/events/message.groups https://api.slack.com/events/message.im https://api.slack.com/events/message.mpim
func ReactionHandler ¶
https://api.slack.com/events/reaction_added https://api.slack.com/events/reaction_removed
func URLVerificationHandler ¶
Types ¶
type AppMentionEvent ¶
type AppMentionEvent struct { Type string `json:"type,omitempty"` User string `json:"user,omitempty"` Team string `json:"team,omitempty"` Channel string `json:"channel,omitempty"` TS string `json:"ts,omitempty"` EventTS string `json:"event_ts,omitempty"` Text string `json:"text,omitempty"` Blocks []map[string]any `json:"blocks,omitempty"` ClientMsgID string `json:"client_msg_id,omitempty"` }
type Authorization ¶
type Authorization struct { EnterpriseID string `json:"enterprise_id,omitempty"` TeamID string `json:"team_id,omitempty"` UserID string `json:"user_id,omitempty"` IsBot bool `json:"is_bot,omitempty"` IsEnterpriseInstall bool `json:"is_enterprise_install,omitempty"` }
https://api.slack.com/apis/connections/events-api#authorizations
type Callback ¶
type Callback struct { // The workspace/team where this event occurred. TeamID string `json:"team_id,omitempty"` ContextTeamID string `json:"context_team_id,omitempty"` // TODO: context_enterprise_id // The application this event is intended for. APIAppID string `json:"api_app_id,omitempty"` // Typically, this is "event_callback" or "url_verification". // See also the event field's "inner event" type. Type string `json:"type,omitempty"` // Contains the inner set of fields representing the event that's happening. Event *Event `json:"event,omitempty"` // An installation of your app. Installations are defined by a combination // (1 or 2) of the installing Enterprise Grid org, workspace, and user. Authorizations []Authorization `json:"authorizations,omitempty"` // An identifier for this specific event. Can be used with the // https://api.slack.com/methods/apps.event.authorizations.list method to // obtain a full list of app installations for which this event is visible. // See also: https://api.slack.com/changelog/2020-09-15-events-api-truncate-authed-users#full_list. EventContext string `json:"event_context,omitempty"` // A unique identifier for this specific event, globally unique across all workspaces. EventID string `json:"event_id,omitempty"` // The epoch timestamp in seconds indicating when this event was dispatched. EventTime int32 `json:"event_time,omitempty"` }
https://api.slack.com/apis/connections/events-api#callback-field https://api.slack.com/types/event
type ChannelCreatedEvent ¶
type ChannelCreatedEvent struct { Type string `json:"type,omitempty"` Channel *conversations.Channel `json:"channel,omitempty"` EventTS string `json:"event_ts,omitempty"` }
type ChannelGroupEvent ¶
type ChannelGroupEvent struct { Type string `json:"type,omitempty"` Channel string `json:"channel,omitempty"` ChannelType string `json:"channel_type,omitempty"` User string `json:"user,omitempty"` Inviter string `json:"inviter,omitempty"` IsMoved bool `json:"is_moved,omitempty"` EventTS string `json:"event_ts,omitempty"` }
https://api.slack.com/events/channel_archive https://api.slack.com/events/channel_unarchive https://api.slack.com/events/group_archive https://api.slack.com/events/group_open https://api.slack.com/events/group_unarchive https://api.slack.com/events/member_joined_channel
type Event ¶
type Event struct { // The specific name of this event - affects parsing. Type string `json:"type,omitempty"` // The timestamp of what the event describes, which may occur slightly prior // to the event being dispatched as described by [EventTS]. The combination // of [TS], [TeamID], [UserID], or [ChannelID] is intended to be unique. TS string `json:"ts,omitempty"` // The timestamp of the event. The combination of [EventTS], [TeamID], // [UserID], or [ChannelID] is intended to be unique. EventTS string `json:"event_ts,omitempty"` // The user ID of to the user that incited this action. Not included in all // events as not all events are controlled by users. User string `json:"user,omitempty"` // Same function as [User], for "channel_member_joined" events. Inviter string `json:"inviter,omitempty"` }
https://api.slack.com/apis/connections/events-api#event-type-structure
type Item ¶
type Item struct { Type string `json:"type,omitempty"` Channel string `json:"channel,omitempty"` TS string `json:"ts,omitempty"` File string `json:"file,omitempty"` FileComment string `json:"file_comment,omitempty"` }
Item is a brief reference to what was reacted to.
type ReactionEvent ¶
type ReactionEvent struct { Type string `json:"type,omitempty"` User string `json:"user,omitempty"` // Emoji name (without ":" on either side). Reaction string `json:"reaction,omitempty"` // Item is a brief reference to what was reacted to. Item *Item `json:"item,omitempty"` // ItemUser is the ID of the user that created the original item that has // been reacted to. Some messages aren't authored by "users," like those // created by incoming webhooks (https://api.slack.com/messaging/webhooks). // Events related to these messages will not include an [ItemUser]. ItemUser string `json:"item_user,omitempty"` EventTS string `json:"event_ts,omitempty"` }
https://api.slack.com/events/reaction_added https://api.slack.com/events/reaction_removed