diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 966668227..d471c8ec6 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -343,6 +343,7 @@ func (al *AgentLoop) Run(ctx context.Context) error { Channel: msg.Channel, ChatID: msg.ChatID, Content: response, + Peer: msg.Peer, }) logger.InfoCF("agent", "Published outbound response", map[string]any{ diff --git a/pkg/bus/types.go b/pkg/bus/types.go index 7ad8f0417..cf2f9ba74 100644 --- a/pkg/bus/types.go +++ b/pkg/bus/types.go @@ -33,6 +33,7 @@ type OutboundMessage struct { Channel string `json:"channel"` ChatID string `json:"chat_id"` Content string `json:"content"` + Peer Peer `json:"peer"` // routing peer (direct, group, etc.) } // MediaPart describes a single media attachment to send. diff --git a/pkg/channels/qq/qq.go b/pkg/channels/qq/qq.go index 112964143..b08bc2735 100644 --- a/pkg/channels/qq/qq.go +++ b/pkg/channels/qq/qq.go @@ -126,13 +126,25 @@ func (c *QQChannel) Send(ctx context.Context, msg bus.OutboundMessage) error { Content: msg.Content, } - // send C2C message - _, err := c.api.PostC2CMessage(ctx, msg.ChatID, msgToCreate) - if err != nil { - logger.ErrorCF("qq", "Failed to send C2C message", map[string]any{ - "error": err.Error(), - }) - return fmt.Errorf("qq send: %w", channels.ErrTemporary) + // Use appropriate API based on peer type + if msg.Peer.Kind == "group" { + // send group message + _, err := c.api.PostGroupMessage(ctx, msg.ChatID, msgToCreate) + if err != nil { + logger.ErrorCF("qq", "Failed to send group message", map[string]any{ + "error": err.Error(), + }) + return fmt.Errorf("qq send: %w", channels.ErrTemporary) + } + } else { + // send C2C (private) message + _, err := c.api.PostC2CMessage(ctx, msg.ChatID, msgToCreate) + if err != nil { + logger.ErrorCF("qq", "Failed to send C2C message", map[string]any{ + "error": err.Error(), + }) + return fmt.Errorf("qq send: %w", channels.ErrTemporary) + } } return nil