Добавлен callback для доставки ответов оператора
Этот коммит содержится в:
@@ -10,6 +10,7 @@ import {
|
|||||||
} from './db.js';
|
} from './db.js';
|
||||||
|
|
||||||
let bot = null;
|
let bot = null;
|
||||||
|
let operatorMessageNotifier = null;
|
||||||
let botStatus = {
|
let botStatus = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
running: false,
|
running: false,
|
||||||
@@ -47,6 +48,10 @@ function buildTelegramOptions(settings) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setOperatorMessageNotifier(callback) {
|
||||||
|
operatorMessageNotifier = callback;
|
||||||
|
}
|
||||||
|
|
||||||
export function getTelegramBridgeStatus() {
|
export function getTelegramBridgeStatus() {
|
||||||
return {
|
return {
|
||||||
...botStatus,
|
...botStatus,
|
||||||
@@ -146,7 +151,7 @@ export async function startTelegramBridge({ logger } = {}) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
createOperatorMessage({
|
const message = createOperatorMessage({
|
||||||
conversationId,
|
conversationId,
|
||||||
siteId: conversation.site_id,
|
siteId: conversation.site_id,
|
||||||
operatorId: operator.id,
|
operatorId: operator.id,
|
||||||
@@ -154,6 +159,10 @@ export async function startTelegramBridge({ logger } = {}) {
|
|||||||
telegramMessageId: String(ctx.message.message_id)
|
telegramMessageId: String(ctx.message.message_id)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (operatorMessageNotifier) {
|
||||||
|
operatorMessageNotifier({ conversation, message, operator });
|
||||||
|
}
|
||||||
|
|
||||||
await ctx.reply(`Answer saved for conversation ${conversationId}.`);
|
await ctx.reply(`Answer saved for conversation ${conversationId}.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user