Добавлен callback для доставки ответов оператора

Этот коммит содержится в:
Виктор
2026-05-08 20:12:41 +09:00
родитель 4f0f374206
Коммит 8ce489a464
+10 -1
Просмотреть файл
@@ -10,6 +10,7 @@ import {
} from './db.js';
let bot = null;
let operatorMessageNotifier = null;
let botStatus = {
enabled: false,
running: false,
@@ -47,6 +48,10 @@ function buildTelegramOptions(settings) {
};
}
export function setOperatorMessageNotifier(callback) {
operatorMessageNotifier = callback;
}
export function getTelegramBridgeStatus() {
return {
...botStatus,
@@ -146,7 +151,7 @@ export async function startTelegramBridge({ logger } = {}) {
return;
}
createOperatorMessage({
const message = createOperatorMessage({
conversationId,
siteId: conversation.site_id,
operatorId: operator.id,
@@ -154,6 +159,10 @@ export async function startTelegramBridge({ logger } = {}) {
telegramMessageId: String(ctx.message.message_id)
});
if (operatorMessageNotifier) {
operatorMessageNotifier({ conversation, message, operator });
}
await ctx.reply(`Answer saved for conversation ${conversationId}.`);
});