feat(mom): backfill missed messages on startup using conversations.history API
- Add getLastTimestamp() to ChannelStore to read last ts from log.jsonl - Add backfillChannel() to fetch up to 3 pages (3000 messages) per channel - Add backfillAllChannels() called in start() before socket connection - Include mom's own messages (as bot) and user messages, exclude other bots - Process attachments from backfilled messages - Add logging: logBackfillStart, logBackfillChannel, logBackfillComplete - Warn if attachment missing name instead of failing fixes #103
This commit is contained in:
@@ -242,3 +242,17 @@ export function logConnected(): void {
|
||||
export function logDisconnected(): void {
|
||||
console.log("Mom bot disconnected.");
|
||||
}
|
||||
|
||||
// Backfill
|
||||
export function logBackfillStart(channelCount: number): void {
|
||||
console.log(chalk.blue(`${timestamp()} [system] Backfilling ${channelCount} channels...`));
|
||||
}
|
||||
|
||||
export function logBackfillChannel(channelName: string, messageCount: number): void {
|
||||
console.log(chalk.blue(`${timestamp()} [system] #${channelName}: ${messageCount} messages`));
|
||||
}
|
||||
|
||||
export function logBackfillComplete(totalMessages: number, durationMs: number): void {
|
||||
const duration = (durationMs / 1000).toFixed(1);
|
||||
console.log(chalk.blue(`${timestamp()} [system] Backfill complete: ${totalMessages} messages in ${duration}s`));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user