- Rewrote bot/index.js using grammy (@grammyjs/auto-retry + runner) - Added deduplication.js (adapted from claudegram) - Added request-queue.js (per-chat sequential processing) - Added message-sender.js (chunking + Markdown fallback) - Wired all JS-shim services: tools, skills, agents, config, RTK - Added function calling support to ZAIProvider.chat() - Added dynamic command routing (tools, skills, agents, model, stats) - Added per-agent delegation commands (/agent_coder, /agent_architect, etc.) - Added dedup + queue patterns from claudegram's battle-tested codebase - Updated zcode.js to pass agents to initBot() - Updated README feature comparison table to reflect real capabilities
28 lines
772 B
JavaScript
28 lines
772 B
JavaScript
// Copied from claudegram — proven deduplication pattern
|
|
const processedMessages = new Map();
|
|
const MESSAGE_TTL = 60000;
|
|
let cleanupInterval = null;
|
|
|
|
export function isDuplicate(messageId) {
|
|
return processedMessages.has(messageId);
|
|
}
|
|
|
|
export function markProcessed(messageId) {
|
|
processedMessages.set(messageId, Date.now());
|
|
ensureCleanupRunning();
|
|
}
|
|
|
|
function ensureCleanupRunning() {
|
|
if (cleanupInterval) return;
|
|
cleanupInterval = setInterval(() => {
|
|
const now = Date.now();
|
|
for (const [id, timestamp] of processedMessages) {
|
|
if (now - timestamp > MESSAGE_TTL) processedMessages.delete(id);
|
|
}
|
|
if (processedMessages.size === 0 && cleanupInterval) {
|
|
clearInterval(cleanupInterval);
|
|
cleanupInterval = null;
|
|
}
|
|
}, 30000);
|
|
}
|