slack

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultReminderTime = "8:00AM"
)
View Source
const (
	ErrLinkAuthzTimeout = "link not authorized yet" // For some reason errors.Is() doesn't work across Temporal.
)
View Source
const ExpectedSubmatches = 6

Variables

View Source
var Schedules = []string{
	"slack.schedules.reminders",
}

Schedules is a list of workflow names that RevChat runs periodically via Temporal schedules (https://docs.temporal.io/develop/go/schedules).

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

	"slack.events.channel_archive",
	"slack.events.group_archive",
	"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, private bool) (string, bool, error)

func CreateSchedule added in v0.5.0

func CreateSchedule(ctx context.Context, c client.Client, cmd *cli.Command)

CreateSchedule starts a scheduled workflow that runs every 30 minutes.

func DeleteMessage added in v0.4.0

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

func DrainSignals added in v0.7.0

func DrainSignals(ctx workflow.Context, taskQueue string) bool

DrainSignals drains all pending Signals channels, starts their corresponding workflows as usual, and returns true if any signals were found. This is called in preparation for resetting the dispatcher workflow's history.

func InviteUsersToChannel added in v0.4.0

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

func KickUsersFromChannel added in v0.5.0

func KickUsersFromChannel(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 their registered workflows.

func RegisterWorkflows added in v0.3.0

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

RegisterWorkflows maps event-handling workflow functions to Signals.

func RenameChannel added in v0.5.0

func RenameChannel(ctx workflow.Context, channelID, name string) (bool, error)

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 {
	// contains filtered or unexported fields
}

type Edited added in v0.7.0

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

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"`
	SourceTeam string `json:"source_team,omitempty"`
	UserTeam   string `json:"user_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".

	ReplyCount      int      `json:"reply_count,omitempty"`
	ReplyUsers      []string `json:"reply_users,omitempty"`
	ReplyUsersCount int      `json:"reply_users_count,omitempty"`
	LatestReply     string   `json:"latest_reply,omitempty"`

	Hidden     bool   `json:"hidden,omitempty"`
	IsLocked   bool   `json:"is_locked,omitempty"`
	Subscribed bool   `json:"subscribed,omitempty"`
	LastRead   string `json:"last_read,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