NestJS Telegraf - 用于多个电报机器人的 Webhook

问题描述 投票:0回答:1

为单个机器人设置 Webhook 似乎可行,但一旦添加另一个机器人,我就开始收到错误:

Error: listen EADDRINUSE: address already in use :::80

以下是我为每个机器人设置 TelegrafModule 的方法:

TelegrafModule.forRootAsync({
          botName: 'bot-name1'
          useFactory: () => ({
            token: 'bot-token1'
            launchOptions: {
              webhook: {
                port: 80,
                domain: 'my-domain'
                hookPath: '/bot-username1',
              },
            },
            include: [TelegramBotModule],
          })

TelegrafModule.forRootAsync({
          botName: 'bot-name2'
          useFactory: () => ({
            token: 'bot-token2'
            launchOptions: {
              webhook: {
                port: 80,
                domain: 'my-domain'
                hookPath: '/bot-username2',
              },
            },
            include: [TelegramBotModule],
          })

这是我在 main.ts 中监听 webhooks 的方式:

const bot = app.get(getBotToken('bot-name1'));
const bot2 = app.get(getBotToken('bot-name2'));

app.use(bot.webhookCallback('/bot-username1'));
app.use(bot2.webhookCallback('/bot-username1'));

我还尝试对两个机器人使用相同的挂钩路径,并得到相同的错误。 (/秘密路径)

node.js nestjs telegram telegram-bot telegraf
1个回答
0
投票

问题解决了吗?你是怎么决定的?我也有类似的情况

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.