fix(qq): use PostGroupMessage for group chat responses
The QQ channel was incorrectly using PostC2CMessage (private message API) for all messages, including group messages. This caused error code 11255 when replying to @mentions in QQ groups. Changes: - Add Peer field to OutboundMessage struct - Check msg.Peer.Kind in QQ Send method - Use PostGroupMessage for group messages - Use PostC2CMessage for direct/private messages - Pass Peer info when publishing outbound messages Fixes #1221
This commit is contained in:
parent
3738040987
commit
9740b547ea
3 changed files with 21 additions and 7 deletions
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -126,7 +126,18 @@ func (c *QQChannel) Send(ctx context.Context, msg bus.OutboundMessage) error {
|
|||
Content: msg.Content,
|
||||
}
|
||||
|
||||
// send C2C message
|
||||
// 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{
|
||||
|
|
@ -134,6 +145,7 @@ func (c *QQChannel) Send(ctx context.Context, msg bus.OutboundMessage) error {
|
|||
})
|
||||
return fmt.Errorf("qq send: %w", channels.ErrTemporary)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue