mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
931093c19d
Add bus.Peer struct and explicit Peer/MessageID fields to InboundMessage,
replacing the implicit peer_kind/peer_id/message_id metadata convention.
- Add Peer{Kind, ID} type to pkg/bus/types.go
- Extend InboundMessage with Peer and MessageID fields
- Change BaseChannel.HandleMessage signature to accept peer and messageID
- Adapt all 12 channel implementations to pass structured peer/messageID
- Simplify agent extractPeer() to read msg.Peer directly
- extractParentPeer unchanged (parent_peer still via metadata)
28 lines
931 B
Go
28 lines
931 B
Go
package bus
|
|
|
|
// Peer identifies the routing peer for a message (direct, group, channel, etc.)
|
|
type Peer struct {
|
|
Kind string `json:"kind"` // "direct" | "group" | "channel" | ""
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
type InboundMessage struct {
|
|
Channel string `json:"channel"`
|
|
SenderID string `json:"sender_id"`
|
|
ChatID string `json:"chat_id"`
|
|
Content string `json:"content"`
|
|
Media []string `json:"media,omitempty"`
|
|
Peer Peer `json:"peer"` // routing peer
|
|
MessageID string `json:"message_id,omitempty"` // platform message ID
|
|
SessionKey string `json:"session_key"`
|
|
Metadata map[string]string `json:"metadata,omitempty"`
|
|
}
|
|
|
|
type OutboundMessage struct {
|
|
Channel string `json:"channel"`
|
|
ChatID string `json:"chat_id"`
|
|
Content string `json:"content"`
|
|
}
|
|
|
|
type MessageHandler func(InboundMessage) error
|