Ночная проверка: сообщение бота об ошибке не считается ответом, упавшие сообщения берутся всегда
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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 }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user