forked from NayanUnni95/TelegramBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
18 lines (16 loc) · 649 Bytes
/
app.js
File metadata and controls
18 lines (16 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const TelegramBot = require('node-telegram-bot-api');
require('dotenv').config();
const { eventController } = require('./src/controller/eventController');
const { messageController } = require('./src/controller/messageController');
const token = process.env.Token || null;
const bot = new TelegramBot(token, {
polling: { interval: 3000, autoStart: true, params: { timeout: 30 } },
});
bot.on('message', (msg) => messageController(bot, msg));
bot.on('callback_query', (query) => eventController(bot, query));
bot.on('polling_error', (err) => {
console.log(`Error Details : ${err}`);
setTimeout(() => {
bot.startPolling();
}, 5000);
});