mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
8116bcb6bc
Channels previously deleted downloaded media files via defer os.Remove, racing with the async Agent consumer. Introduce MediaStore to decouple file ownership: channels register files on download, Agent releases them after processing via ReleaseAll(scope). - New pkg/media with MediaStore interface + FileMediaStore implementation - InboundMessage gains MediaScope field for lifecycle tracking - BaseChannel gains SetMediaStore/GetMediaStore + BuildMediaScope helper - Manager injects MediaStore into channels; AgentLoop releases on completion - Telegram, Discord, Slack, OneBot, LINE channels migrated from defer os.Remove to store.Store() with media:// refs
29 lines
1019 B
Go
29 lines
1019 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
|
|
MediaScope string `json:"media_scope,omitempty"` // media lifecycle scope
|
|
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
|