@gonzih/cc-tg 0.9.12 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bot.js +22 -2
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -544,11 +544,31 @@ export class CcTgBot {
|
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
catch (err) {
|
|
547
|
+
const errMsg = err.message;
|
|
547
548
|
failed++;
|
|
548
|
-
errors.push(`${fileId}: ${
|
|
549
|
+
errors.push(`${fileId}: ${errMsg}`);
|
|
550
|
+
// Permanently unretryable (expired Telegram link) — remove from voice:pending
|
|
551
|
+
if (errMsg.includes("Bad Request") || errMsg.includes("file_id")) {
|
|
552
|
+
const matchPending = pendingRaw.find((r) => r.includes(`"${fileId}"`));
|
|
553
|
+
if (matchPending)
|
|
554
|
+
await this.redis.lrem("voice:pending", 0, matchPending).catch(() => { });
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
// Purge stale entries from voice:pending older than 48h
|
|
559
|
+
const staleThreshold = 48 * 60 * 60 * 1000;
|
|
560
|
+
let purged = 0;
|
|
561
|
+
for (const raw of pendingRaw) {
|
|
562
|
+
try {
|
|
563
|
+
const entry = JSON.parse(raw);
|
|
564
|
+
if (entry.timestamp && Date.now() - entry.timestamp > staleThreshold) {
|
|
565
|
+
await this.redis.lrem("voice:pending", 0, raw).catch(() => { });
|
|
566
|
+
purged++;
|
|
567
|
+
}
|
|
549
568
|
}
|
|
569
|
+
catch { /* skip malformed entries */ }
|
|
550
570
|
}
|
|
551
|
-
const lines = [`Voice retry complete: ${succeeded} succeeded, ${failed} failed.`];
|
|
571
|
+
const lines = [`Voice retry complete: ${succeeded} succeeded, ${failed} failed, ${purged} stale entries purged.`];
|
|
552
572
|
if (errors.length > 0)
|
|
553
573
|
lines.push(...errors.map((e) => `• ${e}`));
|
|
554
574
|
await this.replyToChat(chatId, lines.join("\n"), threadId);
|