forked from hczhcz/telegram-kuso-bots
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.tg.js
More file actions
32 lines (26 loc) · 694 Bytes
/
bot.tg.js
File metadata and controls
32 lines (26 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const TelegramBot = require('node-telegram-bot-api');
process.on('uncaughtException', (err) => {
console.error(Date());
console.error(err);
});
module.exports = (token) => {
const bot = new TelegramBot(token, {
polling: {
interval: 1000,
},
});
bot.on('error', (err) => {
if (!(err instanceof TelegramBot.errors.ParseError)) {
console.error(Date());
console.error(err);
}
});
bot.on('polling_error', (err) => {
if (!(err instanceof TelegramBot.errors.ParseError)) {
console.error(Date());
console.error(err);
}
});
return bot;
};