local

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BotUserID is the user ID for the local bot.
	BotUserID = "loop-bot"

	// BotUsername is the bot name used for @mention detection on local platform.
	BotUsername = "LoopBot"

	// DefaultAuthorID is the default author for local platform messages.
	DefaultAuthorID = "local-user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	// contains filtered or unexported fields
}

Bot is the local platform bot. It implements orchestrator.Bot with DB-backed thread/channel operations, and api.IncomingMessageHandler for routing API messages through the orchestrator.

func NewBot

func NewBot(store LocalStore, logger *slog.Logger) *Bot

NewBot creates a new local platform Bot.

func (*Bot) BotUserID

func (b *Bot) BotUserID() string

func (*Bot) CreateChannel

func (b *Bot) CreateChannel(_ context.Context, _ string) (string, error)

func (*Bot) CreateSimpleThread

func (b *Bot) CreateSimpleThread(ctx context.Context, channelID, name, initialMessage string) (string, error)

func (*Bot) CreateThread

func (b *Bot) CreateThread(ctx context.Context, channelID, name, _, message string) (string, error)

func (*Bot) DeleteThread

func (b *Bot) DeleteThread(ctx context.Context, threadID string) error

func (*Bot) GetChannelName

func (b *Bot) GetChannelName(ctx context.Context, channelID string) (string, error)

func (*Bot) GetChannelParentID

func (b *Bot) GetChannelParentID(ctx context.Context, channelID string) (string, error)

func (*Bot) GetOwnerUserID

func (b *Bot) GetOwnerUserID(_ context.Context) (string, error)

func (*Bot) HandleIncomingMessage

func (b *Bot) HandleIncomingMessage(ctx context.Context, channelID, authorID, content, mode string)

HandleIncomingMessage implements api.IncomingMessageHandler. It parses mentions and command prefixes, then routes the message through the orchestrator.

func (*Bot) HandleThreadCreated

func (b *Bot) HandleThreadCreated(ctx context.Context, threadID, authorID, message string)

HandleThreadCreated implements api.IncomingMessageHandler. It routes the initial thread message as a bot mention to trigger the agent.

func (*Bot) InviteUserToChannel

func (b *Bot) InviteUserToChannel(_ context.Context, _, _ string) error

func (*Bot) IsBotUser

func (b *Bot) IsBotUser(userID string) bool

func (*Bot) OnChannelDelete

func (b *Bot) OnChannelDelete(handler func(ctx context.Context, channelID string, isThread bool))

func (*Bot) OnChannelJoin

func (b *Bot) OnChannelJoin(handler func(ctx context.Context, channelID string, platform types.Platform))

func (*Bot) OnInteraction

func (b *Bot) OnInteraction(handler func(ctx context.Context, i *bot.Interaction))

func (*Bot) OnMessage

func (b *Bot) OnMessage(handler func(ctx context.Context, msg *bot.IncomingMessage))

func (*Bot) PostMessage

func (b *Bot) PostMessage(_ context.Context, _, _ string) error

func (*Bot) RegisterCommands

func (b *Bot) RegisterCommands(_ context.Context) error

func (*Bot) RemoveCommands

func (b *Bot) RemoveCommands(_ context.Context) error

func (*Bot) RemoveStopButton

func (b *Bot) RemoveStopButton(_ context.Context, _, _ string) error

func (*Bot) RenameThread

func (b *Bot) RenameThread(ctx context.Context, threadID, name string) error

func (*Bot) SendMessage

func (b *Bot) SendMessage(_ context.Context, _ *bot.OutgoingMessage) error

func (*Bot) SendStopButton

func (b *Bot) SendStopButton(_ context.Context, _, _ string) (string, error)

func (*Bot) SendTyping

func (b *Bot) SendTyping(_ context.Context, _ string) error

func (*Bot) SetChannelTopic

func (b *Bot) SetChannelTopic(_ context.Context, _, _ string) error

func (*Bot) Start

func (b *Bot) Start(ctx context.Context) error

func (*Bot) Stop

func (b *Bot) Stop() error

type LocalStore

type LocalStore interface {
	GetChannel(ctx context.Context, channelID string) (*db.Channel, error)
	UpsertChannel(ctx context.Context, ch *db.Channel) error
	DeleteChannel(ctx context.Context, channelID string) error
	InsertMessage(ctx context.Context, msg *db.Message) error
}

LocalStore is the subset of db.Store needed by Bot.

Jump to

Keyboard shortcuts

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