From 041a40e804acd2cfde6eff473bdd4760e9db82ca Mon Sep 17 00:00:00 2001 From: mingmxren Date: Sun, 1 Mar 2026 02:27:54 +0800 Subject: [PATCH] feat(channels): add optional command registrar capability interface --- pkg/channels/interfaces.go | 9 +++++++++ pkg/channels/interfaces_command_test.go | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 pkg/channels/interfaces_command_test.go diff --git a/pkg/channels/interfaces.go b/pkg/channels/interfaces.go index 74caeeac5..42f18405c 100644 --- a/pkg/channels/interfaces.go +++ b/pkg/channels/interfaces.go @@ -2,6 +2,8 @@ package channels import "context" +import "github.com/sipeed/picoclaw/pkg/commands" + // TypingCapable — channels that can show a typing/thinking indicator. // StartTyping begins the indicator and returns a stop function. // The stop function MUST be idempotent and safe to call multiple times. @@ -39,3 +41,10 @@ type PlaceholderRecorder interface { RecordTypingStop(channel, chatID string, stop func()) RecordReactionUndo(channel, chatID string, undo func()) } + +// CommandRegistrarCapable is implemented by channels that can register +// command menus with their upstream platform (e.g. Telegram BotCommand). +// Channels that do not support platform-level command menus can ignore it. +type CommandRegistrarCapable interface { + RegisterCommands(ctx context.Context, defs []commands.Definition) error +} diff --git a/pkg/channels/interfaces_command_test.go b/pkg/channels/interfaces_command_test.go new file mode 100644 index 000000000..de5502644 --- /dev/null +++ b/pkg/channels/interfaces_command_test.go @@ -0,0 +1,16 @@ +package channels + +import ( + "context" + "testing" + + "github.com/sipeed/picoclaw/pkg/commands" +) + +type mockRegistrar struct{} + +func (mockRegistrar) RegisterCommands(context.Context, []commands.Definition) error { return nil } + +func TestCommandRegistrarCapable_Compiles(t *testing.T) { + var _ CommandRegistrarCapable = mockRegistrar{} +}