Documentation
¶
Index ¶
- type ChannelDeleteHandler
- type ChannelJoinHandler
- type IncomingMessage
- type InteractionHandler
- type MessageHandler
- type OutgoingMessage
- type SlackBot
- func (b *SlackBot) BotUserID() string
- func (b *SlackBot) CreateChannel(ctx context.Context, _, name 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) GetOwnerUserID(ctx context.Context) (string, error)
- func (b *SlackBot) InviteUserToChannel(ctx context.Context, channelID, userID string) error
- func (b *SlackBot) OnChannelDelete(handler ChannelDeleteHandler)
- func (b *SlackBot) OnChannelJoin(handler ChannelJoinHandler)
- func (b *SlackBot) OnInteraction(handler InteractionHandler)
- func (b *SlackBot) OnMessage(handler 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) SendMessage(ctx context.Context, msg *OutgoingMessage) 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 ChannelDeleteHandler ¶
ChannelDeleteHandler is a callback for channel deletion events.
type ChannelJoinHandler ¶ added in v0.1.22
ChannelJoinHandler is a callback for when the bot joins a channel.
type IncomingMessage ¶
type IncomingMessage = orchestrator.IncomingMessage
IncomingMessage is an alias for orchestrator.IncomingMessage.
type InteractionHandler ¶
InteractionHandler is a callback for slash command interactions.
type MessageHandler ¶
type MessageHandler = func(ctx context.Context, msg *IncomingMessage)
MessageHandler is a callback for incoming messages.
type OutgoingMessage ¶
type OutgoingMessage = orchestrator.OutgoingMessage
OutgoingMessage is an alias for orchestrator.OutgoingMessage.
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) 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 its parent message.
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) 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 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 ChannelJoinHandler)
OnChannelJoin registers a handler to be called when the bot joins a channel.
func (*SlackBot) OnInteraction ¶
func (b *SlackBot) OnInteraction(handler InteractionHandler)
OnInteraction registers a handler to be called for slash command interactions.
func (*SlackBot) OnMessage ¶
func (b *SlackBot) OnMessage(handler 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) SendMessage ¶
func (b *SlackBot) SendMessage(ctx context.Context, msg *OutgoingMessage) error
SendMessage sends one or more messages to Slack, splitting at 4000 chars.
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)
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.