Telegraf Webhook Multiple Bots
rain
typescript
2 years ago
620 B
9
Indexable
import "dotenv/config"; import express from "express"; import { Telegraf } from "telegraf"; const env = process.env; const bot1 = new Telegraf(env.BOT_TOKEN_1); const bot2 = new Telegraf(env.BOT_TOKEN_2); const server = express(); const bots = [bot1, bot2]; const totalBots = bots.length; const port = env.PORT || 8080; const domain = env.WEBHOOK_URL; // for example: https://telegraf-webhook.username.repl.co for (let i = 0; i < totalBots; i++) { server.use( await bot[i].createWebhook({ domain, path: "/" + i, }) ); } server.listen(port, () => console.log(`Server listening on ${port}`));
Editor is loading...