slack

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ExpectedSubmatches = 6

Variables

View Source
var Signals = []string{
	"slack.events.app_rate_limited",

	"slack.events.member_joined_channel",
	"slack.events.member_left_channel",
	"slack.events.message",
	"slack.events.reaction_added",
	"slack.events.reaction_removed",

	"slack.events.slash_command",
}

Signals is a list of signal names that RevChat receives from Timpani, to trigger event handling workflows.

This is based on:

Functions

func CreateChannel added in v0.4.0

func CreateChannel(ctx workflow.Context, name, url string) (string, bool, error)

func DeleteMessage added in v0.4.0

func DeleteMessage(ctx workflow.Context, channelID, timestamp string) error

func InviteUsersToChannel added in v0.4.0

func InviteUsersToChannel(ctx workflow.Context, channelID string, userIDs []string) error

func NormalizeChannelName

func NormalizeChannelName(name string, maxLen int) string

NormalizeChannelName transforms arbitrary text into a valid Slack channel name. Based on: https://docs.slack.dev/reference/methods/conversations.create#naming.

func PostEphemeralMessage added in v0.4.0

func PostEphemeralMessage(ctx workflow.Context, channelID, userID, msg string) error

func PostMessage added in v0.4.0

func PostMessage(ctx workflow.Context, channelID, msg string) (*slack.ChatPostMessageResponse, error)

func PostMessageAsUser added in v0.4.0

func PostMessageAsUser(ctx workflow.Context, channelID, name, icon, msg string) (*slack.ChatPostMessageResponse, error)

func PostReply added in v0.4.0

func PostReply(ctx workflow.Context, channelID, timestamp, msg string) (*slack.ChatPostMessageResponse, error)

func PostReplyAsUser added in v0.4.0

func PostReplyAsUser(ctx workflow.Context, channelID, timestamp, name, icon, msg string) (*slack.ChatPostMessageResponse, error)

func RegisterSignals added in v0.3.0

func RegisterSignals(ctx workflow.Context, sel workflow.Selector, taskQueue string)

RegisterSignals routes Signals to registered workflows.

func RegisterWorkflows added in v0.3.0

func RegisterWorkflows(w worker.Worker, cmd *cli.Command)

RegisterWorkflows maps event handler functions to Signals.

func SetChannelDescription added in v0.4.0

func SetChannelDescription(ctx workflow.Context, channelID, title, url string)

func SetChannelTopic added in v0.4.0

func SetChannelTopic(ctx workflow.Context, channelID, url string)

func UpdateMessage added in v0.4.0

func UpdateMessage(ctx workflow.Context, channelID, timestamp, msg string) error

Types

type Config added in v0.3.0

type Config struct {
	Cmd *cli.Command
}

type MemberEvent added in v0.3.0

type MemberEvent struct {
	Enterprise  string `json:"enterprise,omitempty"`
	Team        string `json:"team"`
	Channel     string `json:"channel"`
	ChannelType string `json:"channel_type"`
	User        string `json:"user"`

	Inviter string `json:"inviter,omitempty"`
}

https://docs.slack.dev/reference/events/member_joined_channel/ https://docs.slack.dev/reference/events/member_left_channel/

type MessageEvent added in v0.3.0

type MessageEvent struct {
	Subtype string `json:"subtype,omitempty"`

	User     string `json:"user,omitempty"`
	BotID    string `json:"bot_id,omitempty"`
	Username string `json:"username,omitempty"` // Customized display name, when bot_id is present.

	Team        string `json:"team,omitempty"`
	Channel     string `json:"channel,omitempty"`
	ChannelType string `json:"channel_type,omitempty"`

	Text string `json:"text,omitempty"`

	Edited          *edited       `json:"edited,omitempty"`           // Subtype = "message_changed".
	Message         *MessageEvent `json:"message,omitempty"`          // Subtype = "message_changed".
	PreviousMessage *MessageEvent `json:"previous_message,omitempty"` // Subtype = "message_changed" or "message_deleted".
	Root            *MessageEvent `json:"root,omitempty"`             // Subtype = "thread_broadcast".

	TS        string `json:"ts"`
	EventTS   string `json:"event_ts,omitempty"`
	DeletedTS string `json:"deleted_ts,omitempty"` // Subtype = "message_deleted".
	ThreadTS  string `json:"thread_ts,omitempty"`  // Reply, or subtype = "thread_broadcast".

	ParentUserID string `json:"parent_user_id,omitempty"` // Subtype = "thread_broadcast".
	ClientMsgID  string `json:"client_msg_id,omitempty"`
}

https://docs.slack.dev/reference/events/message

type ReactionEvent added in v0.3.0

type ReactionEvent struct {
	User     string `json:"user"`
	Reaction string `json:"reaction"`

	Item struct {
		Type        string `json:"type"`
		Channel     string `json:"channel,omitempty"`
		TS          string `json:"ts,omitempty"`
		File        string `json:"file,omitempty"`
		FileComment string `json:"file_comment,omitempty"`
	} `json:"item"`

	ItemUser string `json:"item_user,omitempty"`

	EventTS string `json:"event_ts"`
}

https://docs.slack.dev/reference/events/reaction_added/ https://docs.slack.dev/reference/events/reaction_removed/

type SlashCommandEvent added in v0.3.0

type SlashCommandEvent struct {
	APIAppID string `json:"api_app_id"`

	IsEnterpriseInstall string `json:"is_enterprise_install"`
	EnterpriseID        string `json:"enterprise_id,omitempty"`
	EnterpriseName      string `json:"enterprise_name,omitempty"`
	TeamID              string `json:"team_id"`
	TeamDomain          string `json:"team_domain"`

	ChannelID   string `json:"channel_id"`
	ChannelName string `json:"channel_name"`
	UserID      string `json:"user_id"`
	UserName    string `json:"user_name"`

	Command string `json:"command"`
	Text    string `json:"text"`

	ResponseURL string `json:"response_url"`
	TriggerID   string `json:"trigger_id"`
}

https://docs.slack.dev/interactivity/implementing-slash-commands/#app_command_handling https://docs.slack.dev/apis/events-api/using-socket-mode#command

Jump to

Keyboard shortcuts

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