Build: Release v2.80.29
This commit is contained in:
@@ -224,17 +224,47 @@ export class TelegramBot {
|
||||
reply = `⚠️ Astra 처리 중 오류: ${e?.message ?? e}`;
|
||||
}
|
||||
|
||||
if (reply == null || !reply.trim()) return;
|
||||
try {
|
||||
await this._deps.client.sendMessage({
|
||||
chatId,
|
||||
text: reply,
|
||||
signal: this._abort?.signal,
|
||||
});
|
||||
} catch (e: any) {
|
||||
// Sending the reply failed — log and move on. Don't tear down the
|
||||
// loop because of a single send failure.
|
||||
logError('Telegram reply send failed.', { chatId, error: e?.message ?? String(e) });
|
||||
if (reply == null) {
|
||||
// Handler intentionally suppressed (e.g. allowlist drop). Different
|
||||
// from an empty string — empty means we tried and got nothing back,
|
||||
// which is a bug we want to know about.
|
||||
return;
|
||||
}
|
||||
if (!reply.trim()) {
|
||||
logError('Telegram reply was empty after handle(). Sending placeholder so the user knows the bot is alive.', { chatId });
|
||||
reply = '⚠️ 빈 응답이 생성되었습니다. 다시 시도해주세요.';
|
||||
}
|
||||
|
||||
// One-shot retry on transient send failures (network blip, Telegram
|
||||
// rate-limit). The previous behavior — log once and move on — was the
|
||||
// most likely cause of the "messages disappear sometimes" report:
|
||||
// the AI replied successfully, but the send never reached Telegram
|
||||
// and we never retried.
|
||||
let sent = false;
|
||||
for (let attempt = 0; attempt < 2 && !sent; attempt++) {
|
||||
try {
|
||||
await this._deps.client.sendMessage({
|
||||
chatId,
|
||||
text: reply,
|
||||
signal: this._abort?.signal,
|
||||
});
|
||||
sent = true;
|
||||
logInfo('Telegram reply sent.', { chatId, chars: reply.length, attempt });
|
||||
} catch (e: any) {
|
||||
logError('Telegram reply send failed.', {
|
||||
chatId, attempt, error: e?.message ?? String(e),
|
||||
});
|
||||
if (attempt === 0 && this._running) {
|
||||
// Brief backoff before the retry — don't tight-loop on a
|
||||
// 429 rate limit.
|
||||
await new Promise((r) => {
|
||||
const t = setTimeout(r, 1500);
|
||||
if (typeof t === 'object' && t && 'unref' in t) (t as any).unref();
|
||||
});
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user