mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-08-14 10:25:14 +00:00
Implements 3 coalescing layers to handle rapid multi-attachment inbounds: - Bus debouncer: delays inbound messages 1s, merges duplicates - Web chat debouncer: buffers client-side inbound frames for batch RPC - Telegram album aggregator: collects album members via AfterFunc+Stop timer Drops media-bypass shortcut (forces 1s media floor). Aggregator enforces: - AfterFunc+Stop timer discipline with ordered drain on stop - 2-tuple (album_id, sender) keying for isolation - Dual DoS caps: max 10 albums per sender, max 100 messages per album - merged_message_ids dedup seeding across all 3 surfaces Closes #63
39 lines
1.5 KiB
Go
39 lines
1.5 KiB
Go
package telegram
|
|
|
|
// resolvedMessageContext bundles the post-gate, post-mention-strip state that
|
|
// `handleMessage` computes BEFORE media resolution and downstream dispatch.
|
|
// It is the input contract for `processResolvedMessage` (single message) and
|
|
// for `dispatchAlbum` (album members[0] as the representative).
|
|
//
|
|
// Captured at gate-pass time for the representative message:
|
|
// - identity: userID, senderID, senderLabel
|
|
// - chat addressing: chatID, chatIDStr, localKey
|
|
// - thread metadata: isGroup, isForum, messageThreadID, dmThreadID
|
|
// - resolved cfg: topicCfg (groupPolicy, systemPrompt, skills, tools, allowFrom, ...)
|
|
// - cleaned content: content (text + caption + lightweight tags + reply/forward/location
|
|
// enrichment + stripBotMention applied). For an album flush, this
|
|
// is members[0]'s content snapshot — Telegram puts captions on
|
|
// the first album message only.
|
|
//
|
|
// The carrier *telego.Message is NOT a field here; callers pass it alongside
|
|
// (single: []{message}, album: members). Keeping the message out of the struct
|
|
// lets the album path swap a list of N messages in cleanly without per-member
|
|
// rctx copies.
|
|
type resolvedMessageContext struct {
|
|
content string
|
|
userID string
|
|
senderID string
|
|
senderLabel string
|
|
|
|
chatID int64
|
|
chatIDStr string
|
|
localKey string
|
|
|
|
isGroup bool
|
|
isForum bool
|
|
messageThreadID int
|
|
dmThreadID int
|
|
|
|
topicCfg resolvedTopicConfig
|
|
}
|