Ночная проверка: сообщение бота об ошибке не считается ответом, упавшие сообщения берутся всегда
Some checks failed
ci / deploy (push) Has been cancelled
ci / test (push) Has been cancelled

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-29 09:48:45 +03:00
parent c80816b4c7
commit b106f4141f
2 changed files with 14 additions and 2 deletions

View File

@@ -36,12 +36,13 @@ const BATCH = 50;
/** Сообщения людей без ответа агента: нет сообщения бота в окне после него (и в его треде), текст не служебный. */
export function pickUnanswered(msgs: SlackHistoryMessage[], logged: Map<string, string>): { msg: SlackHistoryMessage; logged: string | null }[] {
const botTs = msgs.filter((m) => m.botId).map((m) => Number(m.ts));
// «Sorry, I could not process your message» - сообщение об ошибке, а не ответ по существу
const botTs = msgs.filter((m) => m.botId && !/could not process your message/i.test(m.text)).map((m) => Number(m.ts));
return msgs
.filter((m) => m.userId && !m.botId && m.text.trim().length >= MIN_TEXT && !/has (joined|left) the channel/i.test(m.text))
.filter((m) => {
const t = Number(m.ts);
return !botTs.some((b) => b > t && b - t <= REPLY_WINDOW_SEC);
return logged.get(m.ts) === "failed" || !botTs.some((b) => b > t && b - t <= REPLY_WINDOW_SEC);
})
.map((m) => ({ msg: m, logged: logged.get(m.ts) ?? null }));
}