diff --git a/pkg/channels/interfaces.go b/pkg/channels/interfaces.go index b10baaa38..4ca975356 100644 --- a/pkg/channels/interfaces.go +++ b/pkg/channels/interfaces.go @@ -3,6 +3,7 @@ package channels import ( "context" + "github.com/sipeed/picoclaw/pkg/bus" "github.com/sipeed/picoclaw/pkg/commands" ) @@ -55,5 +56,5 @@ type CommandRegistrarCapable interface { // This is typically used by internal tools (like TaskTool) that must immediately // receive the generated message ID in order to edit it later. type SyncSender interface { - SendMessageWithID(ctx context.Context, chatID, content string) (string, error) + SendMessageWithID(ctx context.Context, msg bus.OutboundMessage) (string, error) } diff --git a/pkg/channels/manager.go b/pkg/channels/manager.go index ff509279e..c11f6b6d2 100644 --- a/pkg/channels/manager.go +++ b/pkg/channels/manager.go @@ -843,8 +843,14 @@ func (m *Manager) SendMessageWithID(ctx context.Context, channelName, chatID, co return "", fmt.Errorf("channel %s not found", channelName) } + msg := bus.OutboundMessage{ + Channel: channelName, + ChatID: chatID, + Content: content, + } + if syncSender, ok := ch.(SyncSender); ok { - msgID, err := syncSender.SendMessageWithID(ctx, chatID, content) + msgID, err := syncSender.SendMessageWithID(ctx, msg) if err == nil && msgID != "" { return msgID, nil } @@ -854,11 +860,7 @@ func (m *Manager) SendMessageWithID(ctx context.Context, channelName, chatID, co } logger.WarnCF("manager", "falling back to bus publish", nil) - m.bus.PublishOutbound(ctx, bus.OutboundMessage{ - Channel: channelName, - ChatID: chatID, - Content: content, - }) + m.bus.PublishOutbound(ctx, msg) return "", fmt.Errorf("channel does not support returning message ID") }