Documentation
¶
Index ¶
- type SlackBot
- func (b *SlackBot) BotUserID() string
- func (b *SlackBot) CreateChannel(ctx context.Context, _, name string) (string, error)
- func (b *SlackBot) CreateSimpleThread(ctx context.Context, channelID, name, initialMessage string) (string, error)
- func (b *SlackBot) CreateThread(ctx context.Context, channelID, name, mentionUserID, message string) (string, error)
- func (b *SlackBot) DeleteThread(ctx context.Context, threadID string) error
- func (b *SlackBot) GetChannelName(_ context.Context, channelID string) (string, error)
- func (b *SlackBot) GetChannelParentID(_ context.Context, channelID string) (string, error)
- func (b *SlackBot) GetMemberRoles(_ context.Context, _, _ string) ([]string, error)
- func (b *SlackBot) GetOwnerUserID(ctx context.Context) (string, error)
- func (b *SlackBot) InviteUserToChannel(ctx context.Context, channelID, userID string) error
- func (b *SlackBot) OnChannelDelete(handler bot.ChannelDeleteHandler)
- func (b *SlackBot) OnChannelJoin(handler bot.ChannelJoinHandler)
- func (b *SlackBot) OnInteraction(handler bot.InteractionHandler)
- func (b *SlackBot) OnMessage(handler bot.MessageHandler)
- func (b *SlackBot) PostMessage(ctx context.Context, channelID, content string) error
- func (b *SlackBot) RegisterCommands(_ context.Context) error
- func (b *SlackBot) RemoveCommands(_ context.Context) error
- func (b *SlackBot) RemoveStopButton(_ context.Context, channelID, messageID string) error
- func (b *SlackBot) RenameThread(ctx context.Context, threadID, name string) error
- func (b *SlackBot) SendMessage(ctx context.Context, msg *bot.OutgoingMessage) error
- func (b *SlackBot) SendStopButton(_ context.Context, channelID, runID string) (string, error)
- func (b *SlackBot) SendTyping(ctx context.Context, channelID string) error
- func (b *SlackBot) SetChannelTopic(ctx context.Context, channelID, topic string) error
- func (b *SlackBot) Start(ctx context.Context) error
- func (b *SlackBot) Stop() error
- type SlackSession
- type SocketModeClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SlackBot ¶
type SlackBot struct {
// contains filtered or unexported fields
}
SlackBot implements orchestrator.Bot using the Slack API with Socket Mode.
func NewBot ¶
func NewBot(session SlackSession, socketClient SocketModeClient, logger *slog.Logger) *SlackBot
NewBot creates a new SlackBot with the given session, socket mode client, and logger.
func (*SlackBot) CreateChannel ¶
CreateChannel creates a new public Slack channel. If the channel name is already taken, it looks up the existing channel and returns its ID.
func (*SlackBot) CreateSimpleThread ¶ added in v0.1.31
func (b *SlackBot) CreateSimpleThread(ctx context.Context, channelID, name, initialMessage string) (string, error)
CreateSimpleThread creates a new thread with a plain initial message (no bot mention). Returns a composite "channelID:messageTS" thread ID.
func (*SlackBot) CreateThread ¶
func (b *SlackBot) CreateThread(ctx context.Context, channelID, name, mentionUserID, message string) (string, error)
CreateThread creates a new thread by posting an initial message in the channel. Returns a composite ID "channelID:messageTS" that represents the thread.
func (*SlackBot) DeleteThread ¶
DeleteThread deletes a thread by deleting all its messages (replies and parent).
func (*SlackBot) GetChannelName ¶ added in v0.1.22
GetChannelName returns the name of a Slack channel by its ID.
func (*SlackBot) GetChannelParentID ¶
GetChannelParentID returns the parent channel ID for a thread (composite ID), or empty string if not a thread.
func (*SlackBot) GetMemberRoles ¶ added in v0.1.41
GetMemberRoles returns nil for Slack — Slack has no role equivalent. Slack-based access control relies on allow_users only.
func (*SlackBot) GetOwnerUserID ¶ added in v0.1.20
GetOwnerUserID returns the Slack workspace owner's user ID.
func (*SlackBot) InviteUserToChannel ¶
InviteUserToChannel invites a user to a Slack channel.
func (*SlackBot) OnChannelDelete ¶
func (b *SlackBot) OnChannelDelete(handler bot.ChannelDeleteHandler)
OnChannelDelete registers a handler to be called when a channel is deleted.
func (*SlackBot) OnChannelJoin ¶ added in v0.1.22
func (b *SlackBot) OnChannelJoin(handler bot.ChannelJoinHandler)
OnChannelJoin registers a handler to be called when the bot joins a channel.
func (*SlackBot) OnInteraction ¶
func (b *SlackBot) OnInteraction(handler bot.InteractionHandler)
OnInteraction registers a handler to be called for slash command interactions.
func (*SlackBot) OnMessage ¶
func (b *SlackBot) OnMessage(handler bot.MessageHandler)
OnMessage registers a handler to be called for incoming messages.
func (*SlackBot) PostMessage ¶
PostMessage sends a simple message to the given channel or thread. Text mentions of the bot (e.g. @BotName) are converted to proper Slack mentions.
func (*SlackBot) RegisterCommands ¶
RegisterCommands is a no-op for Slack. Commands are registered via the Slack app manifest.
func (*SlackBot) RemoveCommands ¶
RemoveCommands is a no-op for Slack.
func (*SlackBot) RemoveStopButton ¶ added in v0.1.42
RemoveStopButton removes the stop button message by deleting it.
func (*SlackBot) RenameThread ¶ added in v0.1.49
RenameThread renames a Slack thread by doing a find-and-replace on the parent message text. The name parameter is the new thread name; we extract the old and new emoji prefixes and replace only the emoji in the existing message to preserve the original content.
func (*SlackBot) SendMessage ¶
SendMessage sends one or more messages to Slack, splitting at 4000 chars.
func (*SlackBot) SendStopButton ¶ added in v0.1.42
SendStopButton sends a message with a Block Kit "Stop" button.
func (*SlackBot) SendTyping ¶
SendTyping adds an "eyes" emoji reaction to the last received message in the channel and removes it when the context is cancelled.
func (*SlackBot) SetChannelTopic ¶ added in v0.1.21
SetChannelTopic sets the topic/description of a Slack channel.
type SlackSession ¶
type SlackSession interface {
PostMessage(channelID string, options ...goslack.MsgOption) (string, string, error)
DeleteMessage(channel, messageTimestamp string) (string, string, error)
UpdateMessage(channelID, timestamp string, options ...goslack.MsgOption) (string, string, string, error)
AuthTest() (*goslack.AuthTestResponse, error)
CreateConversation(params goslack.CreateConversationParams) (*goslack.Channel, error)
AddReaction(name string, item goslack.ItemRef) error
RemoveReaction(name string, item goslack.ItemRef) error
GetConversationReplies(params *goslack.GetConversationRepliesParameters) ([]goslack.Message, bool, string, error)
InviteUsersToConversation(channelID string, users ...string) (*goslack.Channel, error)
GetConversations(params *goslack.GetConversationsParameters) ([]goslack.Channel, string, error)
GetUsers(options ...goslack.GetUsersOption) ([]goslack.User, error)
SetTopicOfConversation(channelID, topic string) (*goslack.Channel, error)
SetUserPresence(presence string) error
GetConversationInfo(input *goslack.GetConversationInfoInput) (*goslack.Channel, error)
}
SlackSession abstracts the slack.Client methods used by the bot, enabling test mocking.
type SocketModeClient ¶
type SocketModeClient interface {
RunContext(ctx context.Context) error
Ack(req socketmode.Request, payload ...any)
Events() <-chan socketmode.Event
}
SocketModeClient abstracts the socketmode.Client for testability.
func NewSocketModeAdapter ¶
func NewSocketModeAdapter(client *socketmode.Client) SocketModeClient
NewSocketModeAdapter wraps a socketmode.Client as a SocketModeClient.