Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook(s) for multiple telegram bots #1169

Open
royibernthal opened this issue Dec 23, 2023 · 1 comment
Open

Webhook(s) for multiple telegram bots #1169

royibernthal opened this issue Dec 23, 2023 · 1 comment

Comments

@royibernthal
Copy link

royibernthal commented Dec 23, 2023

Setting up a webhook for a single bot seems to work, but once I add another one I'm starting to get an error:
Error: listen EADDRINUSE: address already in use :::80

Here's how I'm settting up the TelegrafModule for each bot:

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],
          })

And here's how I'm listening to the webhooks in main.ts:

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'));

I've also tried using the same hook path for both bots, and got the same error. (/secret-path)

@royibernthal royibernthal changed the title Webhooks for multiple bots Webhook(s) for multiple telegram bots Dec 23, 2023
@evgeny-s
Copy link

You have the same ports.
Just change launchOptions->webhook->port to something else.
This should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants