Documentation
¶
Index ¶
- Constants
- Variables
- func CopyHandlers[T any](mu *sync.RWMutex, handlers []T) []T
- func FindCutPoint(content string, maxLen int) int
- func FormatThreadMessage(botID, botUsername, mentionUserID, message string) string
- func HasCommandPrefix(content string) bool
- func HasTextMention(content, username string) bool
- func RegisterHandler[T any](mu *sync.RWMutex, handlers *[]T, handler T)
- func ReplaceTextMention(content, username, mention string) string
- func SplitMessage(content string, maxLen int) []string
- func StripMention(content, botUserID string) string
- func StripPrefix(content string) string
- func StripTextMention(content, username string) string
- type ChannelDeleteHandler
- type ChannelJoinHandler
- type IncomingMessage
- type Interaction
- type InteractionHandler
- type LocalBot
- func (b *LocalBot) BotUserID() string
- func (b *LocalBot) CreateChannel(_ context.Context, _, _ string) (string, error)
- func (b *LocalBot) CreateSimpleThread(_ context.Context, _, _, _ string) (string, error)
- func (b *LocalBot) CreateThread(_ context.Context, _, _, _, _ string) (string, error)
- func (b *LocalBot) DeleteThread(_ context.Context, _ string) error
- func (b *LocalBot) GetChannelName(_ context.Context, _ string) (string, error)
- func (b *LocalBot) GetChannelParentID(_ context.Context, _ string) (string, error)
- func (b *LocalBot) GetMemberRoles(_ context.Context, _, _ string) ([]string, error)
- func (b *LocalBot) GetOwnerUserID(_ context.Context) (string, error)
- func (b *LocalBot) InviteUserToChannel(_ context.Context, _, _ string) error
- func (b *LocalBot) OnChannelDelete(handler func(ctx context.Context, channelID string, isThread bool))
- func (b *LocalBot) OnChannelJoin(handler func(ctx context.Context, channelID string))
- func (b *LocalBot) OnInteraction(handler func(ctx context.Context, i *Interaction))
- func (b *LocalBot) OnMessage(handler func(ctx context.Context, msg *IncomingMessage))
- func (b *LocalBot) PostMessage(_ context.Context, _, _ string) error
- func (b *LocalBot) RegisterCommands(_ context.Context) error
- func (b *LocalBot) RemoveCommands(_ context.Context) error
- func (b *LocalBot) RemoveStopButton(_ context.Context, _, _ string) error
- func (b *LocalBot) RenameThread(_ context.Context, _, _ string) error
- func (b *LocalBot) SendMessage(_ context.Context, _ *OutgoingMessage) error
- func (b *LocalBot) SendStopButton(_ context.Context, _, _ string) (string, error)
- func (b *LocalBot) SendTyping(_ context.Context, _ string) error
- func (b *LocalBot) SetChannelTopic(_ context.Context, _, _ string) error
- func (b *LocalBot) Start(_ context.Context) error
- func (b *LocalBot) Stop() error
- type MessageHandler
- type OutgoingMessage
Constants ¶
const CommandPrefix = "!loop"
CommandPrefix is the text prefix used to trigger bot commands.
Variables ¶
var RemoveMCPConfig = removeMCPConfig
RemoveMCPConfig removes the per-channel MCP config file for the given channel. It silently ignores os.ErrNotExist (the file may not exist if the agent never ran). This is a variable so external packages can override it in tests.
Functions ¶
func CopyHandlers ¶ added in v0.1.46
CopyHandlers returns a snapshot of the handler slice under a read lock.
func FindCutPoint ¶
FindCutPoint returns the best position to split content at, given a maximum length. It prefers cutting at a newline, then a space, then does a hard cut.
func FormatThreadMessage ¶ added in v0.1.57
FormatThreadMessage builds the initial message for a new thread. It always includes a <@botID> mention so that the bot's event handler recognises the message as a self-mention trigger and starts a new agent run inside the thread. Existing bot mentions (both <@botID> and @username forms) are stripped from message before prepending a canonical <@botID>. If mentionUserID is non-empty the user is appended as a mention.
func HasCommandPrefix ¶
HasCommandPrefix reports whether content starts with the command prefix (case-insensitive).
func HasTextMention ¶ added in v0.1.68
HasTextMention reports whether content contains @username (case-insensitive).
func RegisterHandler ¶ added in v0.1.46
RegisterHandler appends a handler to the slice under the given mutex.
func ReplaceTextMention ¶
ReplaceTextMention replaces a case-insensitive @username with the given mention string.
func SplitMessage ¶
SplitMessage splits a message into chunks of at most maxLen characters, breaking on newlines when possible.
func StripMention ¶
StripMention removes both <@botUserID> and <@!botUserID> forms from content and trims surrounding whitespace.
func StripPrefix ¶
StripPrefix removes the command prefix from content and trims surrounding whitespace.
func StripTextMention ¶ added in v0.1.68
StripTextMention removes the first case-insensitive @username from content and collapses any resulting double spaces.
Types ¶
type ChannelDeleteHandler ¶
ChannelDeleteHandler is a callback for channel/thread deletion events.
type ChannelJoinHandler ¶
ChannelJoinHandler is a callback for when the bot joins a channel.
type IncomingMessage ¶
type IncomingMessage struct {
ChannelID string
GuildID string
AuthorID string
AuthorName string
Content string
MessageID string
IsBotMention bool
IsReplyToBot bool
HasPrefix bool
IsDM bool
Timestamp time.Time
AuthorRoles []string // role IDs for permission checking (Discord only)
}
IncomingMessage from the chat platform.
type Interaction ¶ added in v0.1.58
type Interaction struct {
ChannelID string
GuildID string
CommandName string
Options map[string]string
AuthorID string // user who invoked the command
AuthorRoles []string // role IDs (Discord only)
}
Interaction represents a slash command interaction.
type InteractionHandler ¶
type InteractionHandler = func(ctx context.Context, i *Interaction)
InteractionHandler is a callback for slash command interactions.
type LocalBot ¶ added in v0.1.68
type LocalBot struct {
// contains filtered or unexported fields
}
LocalBot is a no-op bot for the local (non-platform) mode. It implements the orchestrator.Bot interface but performs no platform-specific actions because the orchestrator already handles storing messages and broadcasting events via the API/WebSocket layer.
func NewLocalBot ¶ added in v0.1.68
func NewLocalBot() *LocalBot
NewLocalBot creates a new LocalBot.
func (*LocalBot) CreateChannel ¶ added in v0.1.68
func (*LocalBot) CreateSimpleThread ¶ added in v0.1.68
func (*LocalBot) CreateThread ¶ added in v0.1.68
func (*LocalBot) DeleteThread ¶ added in v0.1.68
func (*LocalBot) GetChannelName ¶ added in v0.1.68
func (*LocalBot) GetChannelParentID ¶ added in v0.1.68
func (*LocalBot) GetMemberRoles ¶ added in v0.1.68
func (*LocalBot) GetOwnerUserID ¶ added in v0.1.68
func (*LocalBot) InviteUserToChannel ¶ added in v0.1.68
func (*LocalBot) OnChannelDelete ¶ added in v0.1.68
func (*LocalBot) OnChannelJoin ¶ added in v0.1.68
func (*LocalBot) OnInteraction ¶ added in v0.1.68
func (b *LocalBot) OnInteraction(handler func(ctx context.Context, i *Interaction))
func (*LocalBot) OnMessage ¶ added in v0.1.68
func (b *LocalBot) OnMessage(handler func(ctx context.Context, msg *IncomingMessage))
func (*LocalBot) PostMessage ¶ added in v0.1.68
func (*LocalBot) RegisterCommands ¶ added in v0.1.68
func (*LocalBot) RemoveCommands ¶ added in v0.1.68
func (*LocalBot) RemoveStopButton ¶ added in v0.1.68
func (*LocalBot) RenameThread ¶ added in v0.1.68
func (*LocalBot) SendMessage ¶ added in v0.1.68
func (b *LocalBot) SendMessage(_ context.Context, _ *OutgoingMessage) error
func (*LocalBot) SendStopButton ¶ added in v0.1.68
func (*LocalBot) SendTyping ¶ added in v0.1.68
func (*LocalBot) SetChannelTopic ¶ added in v0.1.68
type MessageHandler ¶
type MessageHandler = func(ctx context.Context, msg *IncomingMessage)
MessageHandler is a callback for incoming messages.
type OutgoingMessage ¶
OutgoingMessage to the chat platform.