events

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

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 []chat.Block `json:"blocks,omitempty"`

	ClientMsgID string `json:"client_msg_id,omitempty"`
}

https://api.slack.com/events/app_mention

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"`
}

https://api.slack.com/events/channel_created

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

Jump to

Keyboard shortcuts

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