TgRouting/clientExample/index.js

34 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { RmqTelegramBot } from './RmqTelegramBot.js'
// Предположим, что ваш ext.id и имя бота — 'BusinessTrips'
const botName = 'BusinessTrips'
const botToken = еважен_здесь'; // нужен лишь для инициализации, но API не вызывается
import { initRabbit, getChannel } from './utils/rmq.js';
async function main() {
const channel = await initRabbit(process.env.RABBIT_URL || 'amqp://telegram_main:PASSWORD@rabbit.vidi.one:5672/telegram_main');
const bot = new RmqTelegramBot(botName, botToken)
// регистрируем обработчик апдейтов «как обычно»
bot.on('message', async msg => {
console.log('message',msg);
// const resp = await bot.requestSessionState(msg.innerUserId);
// console.log('resp',resp);
// bot.lockSession(msg.innerUserId);
bot.sendMessage(
msg.chat.id,
'Тест окей'
)
})
// ваш сервис не вызывает bot.launch() и не запускает polling/webhook
console.log(`🚀 RMQbot for ${botName} ready, listening InMessage${botName}`)
}
main().catch(console.error)