slackevents

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppMention is an Events API subscribable event
	AppMention = "app_mention"
	// AppUninstalled Your Slack app was uninstalled.
	AppUninstalled = "app_uninstalled"
	// GridMigrationFinished An enterprise grid migration has finished on this workspace.
	GridMigrationFinished = "grid_migration_finished"
	// GridMigrationStarted An enterprise grid migration has started on this workspace.
	GridMigrationStarted = "grid_migration_started"
	// LinkShared A message was posted containing one or more links relevant to your application
	LinkShared = "link_shared"
	// Message A message was posted to a channel, private channel (group), im, or mim
	Message = "message"
	// Member Joined Channel
	MemberJoinedChannel = "member_joined_channel"
	// PinAdded An item was pinned to a channel
	PinAdded = "pin_added"
	// PinRemoved An item was unpinned from a channel
	PinRemoved = "pin_removed"
)
View Source
const (
	// CallbackEvent is the "outer" event of an EventsAPI event.
	CallbackEvent = "event_callback"
	// URLVerification is an event used when configuring your EventsAPI app
	URLVerification = "url_verification"
	// AppRateLimited indicates your app's event subscriptions are being rate limited
	AppRateLimited = "app_rate_limited"
)

Variables

EventsAPIEventMap maps OUTTER Event API events to their corresponding struct implementations. The structs should be instances of the unmarshalling target for the matching event type.

EventsAPIInnerEventMapping maps INNER Event API events to their corresponding struct implementations. The structs should be instances of the unmarshalling target for the matching event type.

Functions

This section is empty.

Types

type AppMentionEvent

type AppMentionEvent struct {
	Type            string      `json:"type"`
	User            string      `json:"user"`
	Text            string      `json:"text"`
	TimeStamp       string      `json:"ts"`
	ThreadTimeStamp string      `json:"thread_ts"`
	Channel         string      `json:"channel"`
	EventTimeStamp  json.Number `json:"event_ts"`
}

AppMentionEvent is an (inner) EventsAPI subscribable event.

type AppUninstalledEvent

type AppUninstalledEvent struct {
	Type string `json:"type"`
}

AppUninstalledEvent Your Slack app was uninstalled.

type ChallengeResponse

type ChallengeResponse struct {
	Challenge string
}

ChallengeResponse is a response to a EventsAPIEvent URLVerification challenge

type Comment added in v0.5.0

type Comment struct {
	ID        string   `json:"id,omitempty"`
	Created   JSONTime `json:"created,omitempty"`
	Timestamp JSONTime `json:"timestamp,omitempty"`
	User      string   `json:"user,omitempty"`
	Comment   string   `json:"comment,omitempty"`
}

Comment contains all the information relative to a comment

type Config

type Config struct {
	VerificationToken string
	TokenVerified     bool
}

type Edited

type Edited struct {
	User      string `json:"user"`
	TimeStamp string `json:"ts"`
}

Edited is included when a Message is edited

type EventsAPIAppRateLimited

type EventsAPIAppRateLimited struct {
	Type              string `json:"type"`
	Token             string `json:"token"`
	TeamID            string `json:"team_id"`
	MinuteRateLimited int    `json:"minute_rate_limited"`
	APIAppID          string `json:"api_app_id"`
}

EventsAPIAppRateLimited indicates your app's event subscriptions are being rate limited

type EventsAPICallbackEvent

type EventsAPICallbackEvent struct {
	Type        string           `json:"type"`
	Token       string           `json:"token"`
	TeamID      string           `json:"team_id"`
	APIAppID    string           `json:"api_app_id"`
	InnerEvent  *json.RawMessage `json:"event"`
	AuthedUsers []string         `json:"authed_users"`
	EventID     string           `json:"event_id"`
	EventTime   int              `json:"event_time"`
}

EventsAPICallbackEvent is the main (outer) EventsAPI event.

type EventsAPIEvent

type EventsAPIEvent struct {
	Token      string `json:"token"`
	TeamID     string `json:"team_id"`
	Type       string `json:"type"`
	Data       interface{}
	InnerEvent EventsAPIInnerEvent
}

EventsAPIEvent is the base EventsAPIEvent

func ParseEvent

func ParseEvent(rawEvent json.RawMessage, opts ...Option) (EventsAPIEvent, error)

ParseEvent parses the outter and inner events (if applicable) of an events api event returning a EventsAPIEvent type. If the event is a url_verification event, the inner event is empty.

type EventsAPIInnerEvent

type EventsAPIInnerEvent struct {
	Type string `json:"type"`
	Data interface{}
}

EventsAPIInnerEvent the inner event of a EventsAPI event_callback Event.

type EventsAPIURLVerificationEvent

type EventsAPIURLVerificationEvent struct {
	Token     string `json:"token"`
	Challenge string `json:"challenge"`
	Type      string `json:"type"`
}

EventsAPIURLVerificationEvent received when configuring a EventsAPI driven app

type File

type File struct {
	ID                 string `json:"id"`
	Created            int    `json:"created"`
	Timestamp          int    `json:"timestamp"`
	Name               string `json:"name"`
	Title              string `json:"title"`
	Mimetype           string `json:"mimetype"`
	Filetype           string `json:"filetype"`
	PrettyType         string `json:"pretty_type"`
	User               string `json:"user"`
	Editable           bool   `json:"editable"`
	Size               int    `json:"size"`
	Mode               string `json:"mode"`
	IsExternal         bool   `json:"is_external"`
	ExternalType       string `json:"external_type"`
	IsPublic           bool   `json:"is_public"`
	PublicURLShared    bool   `json:"public_url_shared"`
	DisplayAsBot       bool   `json:"display_as_bot"`
	Username           string `json:"username"`
	URLPrivate         string `json:"url_private"`
	URLPrivateDownload string `json:"url_private_download"`
	Thumb64            string `json:"thumb_64"`
	Thumb80            string `json:"thumb_80"`
	Thumb360           string `json:"thumb_360"`
	Thumb360W          int    `json:"thumb_360_w"`
	Thumb360H          int    `json:"thumb_360_h"`
	Thumb480           string `json:"thumb_480"`
	Thumb480W          int    `json:"thumb_480_w"`
	Thumb480H          int    `json:"thumb_480_h"`
	Thumb160           string `json:"thumb_160"`
	Thumb720           string `json:"thumb_720"`
	Thumb720W          int    `json:"thumb_720_w"`
	Thumb720H          int    `json:"thumb_720_h"`
	Thumb800           string `json:"thumb_800"`
	Thumb800W          int    `json:"thumb_800_w"`
	Thumb800H          int    `json:"thumb_800_h"`
	Thumb960           string `json:"thumb_960"`
	Thumb960W          int    `json:"thumb_960_w"`
	Thumb960H          int    `json:"thumb_960_h"`
	Thumb1024          string `json:"thumb_1024"`
	Thumb1024W         int    `json:"thumb_1024_w"`
	Thumb1024H         int    `json:"thumb_1024_h"`
	ImageExifRotation  int    `json:"image_exif_rotation"`
	OriginalW          int    `json:"original_w"`
	OriginalH          int    `json:"original_h"`
	Permalink          string `json:"permalink"`
	PermalinkPublic    string `json:"permalink_public"`
}

File is a file upload

type GridMigrationFinishedEvent

type GridMigrationFinishedEvent struct {
	Type         string `json:"type"`
	EnterpriseID string `json:"enterprise_id"`
}

GridMigrationFinishedEvent An enterprise grid migration has finished on this workspace.

type GridMigrationStartedEvent

type GridMigrationStartedEvent struct {
	Type         string `json:"type"`
	EnterpriseID string `json:"enterprise_id"`
}

GridMigrationStartedEvent An enterprise grid migration has started on this workspace.

type Icon

type Icon struct {
	IconURL   string `json:"icon_url,omitempty"`
	IconEmoji string `json:"icon_emoji,omitempty"`
}

Icon is used for bot messages

type Item added in v0.5.0

type Item struct {
	Type      string       `json:"type"`
	Channel   string       `json:"channel,omitempty"`
	Message   *ItemMessage `json:"message,omitempty"`
	File      *File        `json:"file,omitempty"`
	Comment   *Comment     `json:"comment,omitempty"`
	Timestamp string       `json:"ts,omitempty"`
}

Item is any type of slack message - message, file, or file comment.

type ItemMessage added in v0.5.0

type ItemMessage struct {
	Type            string   `json:"type"`
	User            string   `json:"user"`
	Text            string   `json:"text"`
	Timestamp       string   `json:"ts"`
	PinnedTo        []string `json:"pinned_to"`
	ReplaceOriginal bool     `json:"replace_original"`
	DeleteOriginal  bool     `json:"delete_original"`
}

ItemMessage is the event message

type JSONTime added in v0.5.0

type JSONTime int64

JSONTime exists so that we can have a String method converting the date

type LinkSharedEvent

type LinkSharedEvent struct {
	Type             string        `json:"type"`
	User             string        `json:"user"`
	TimeStamp        string        `json:"ts"`
	Channel          string        `json:"channel"`
	MessageTimeStamp json.Number   `json:"message_ts"`
	Links            []sharedLinks `json:"links"`
}

LinkSharedEvent A message was posted containing one or more links relevant to your application

type MemberJoinedChannelEvent added in v0.5.0

type MemberJoinedChannelEvent struct {
	Type        string `json:"type"`
	User        string `json:"user"`
	Channel     string `json:"channel"`
	ChannelType string `json:"channel_type"`
	Team        string `json:"team"`
	Inviter     string `json:"inviter"`
}

MemberJoinedChannelEvent A member join a channel

type MessageAction

type MessageAction struct {
	Type             string                   `json:"type"`
	Actions          []slack.AttachmentAction `json:"actions"`
	CallbackID       string                   `json:"callback_id"`
	Team             MessageActionEntity      `json:"team"`
	Channel          MessageActionEntity      `json:"channel"`
	User             MessageActionEntity      `json:"user"`
	ActionTimestamp  json.Number              `json:"action_ts"`
	MessageTimestamp json.Number              `json:"message_ts"`
	AttachmentID     json.Number              `json:"attachment_id"`
	Token            string                   `json:"token"`
	Message          slack.Message            `json:"message"`
	OriginalMessage  slack.Message            `json:"original_message"`
	ResponseURL      string                   `json:"response_url"`
	TriggerID        string                   `json:"trigger_id"`
}

func ParseActionEvent

func ParseActionEvent(payloadString string, opts ...Option) (MessageAction, error)

type MessageActionEntity

type MessageActionEntity struct {
	ID     string `json:"id"`
	Domain string `json:"domain"`
	Name   string `json:"name"`
}

type MessageActionResponse

type MessageActionResponse struct {
	ResponseType    string `json:"response_type"`
	ReplaceOriginal bool   `json:"replace_original"`
	Text            string `json:"text"`
}

type MessageEvent

type MessageEvent struct {
	// Basic Message Event - https://api.slack.com/events/message
	Type            string      `json:"type"`
	User            string      `json:"user"`
	Text            string      `json:"text"`
	ThreadTimeStamp string      `json:"thread_ts"`
	TimeStamp       string      `json:"ts"`
	Channel         string      `json:"channel"`
	ChannelType     string      `json:"channel_type"`
	EventTimeStamp  json.Number `json:"event_ts"`

	// Edited Message
	Message         *MessageEvent `json:"message,omitempty"`
	PreviousMessage *MessageEvent `json:"previous_message,omitempty"`
	Edited          *Edited       `json:"edited,omitempty"`

	// Message Subtypes
	SubType string `json:"subtype,omitempty"`

	// bot_message (https://api.slack.com/events/message/bot_message)
	BotID    string `json:"bot_id,omitempty"`
	Username string `json:"username,omitempty"`
	Icons    *Icon  `json:"icons,omitempty"`

	Upload bool   `json:"upload"`
	Files  []File `json:"files"`
}

MessageEvent occurs when a variety of types of messages has been posted. Parse ChannelType to see which if ChannelType = "group", this is a private channel message if ChannelType = "channel", this message was sent to a channel if ChannelType = "im", this is a private message if ChannelType = "mim", A message was posted in a multiparty direct message channel TODO: Improve this so that it is not required to manually parse ChannelType

func (MessageEvent) IsEdited

func (e MessageEvent) IsEdited() bool

IsEdited checks if the MessageEvent is caused by an edit

type Option

type Option func(cfg *Config)

func OptionNoVerifyToken added in v0.5.0

func OptionNoVerifyToken() Option

OptionNoVerifyToken skips the check of the Slack verification token

func OptionVerifyToken

func OptionVerifyToken(v verifier) Option

type PinAddedEvent added in v0.5.0

type PinAddedEvent pinEvent

PinAddedEvent An item was pinned to a channel - https://api.slack.com/events/pin_added

type PinRemovedEvent added in v0.5.0

type PinRemovedEvent pinEvent

PinRemovedEvent An item was unpinned from a channel - https://api.slack.com/events/pin_removed

type TokenComparator

type TokenComparator struct {
	VerificationToken string
}

func (TokenComparator) Verify

func (c TokenComparator) Verify(t string) bool

Jump to

Keyboard shortcuts

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