Добавлен callback для доставки ответов оператора
Этот коммит содержится в:
@@ -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}.`);
|
||||
});
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user