-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
50 lines (45 loc) · 1.09 KB
/
bot.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* PiGram
* =====================
* Pi Bash in Telegram Bot
*
* @author: Gabriele De Rosa [@derogab]
* @file: bot.js
* @version: 1.1.6
* @link GitHub Repo: https://github.com/derogab/pigram
*/
/**
* Libs
* =====================
* All config and required open source libs
*/
const { Telegraf } = require('telegraf');
const config = require(__dirname + '/config');
/**
* Init
* =====================
* Get token and username of bot from /config.js
* If not exist rename config.js.tmpl to config.js and change strings
*/
const bot = new Telegraf(config.bot_token, {username: config.bot_username});
/**
* Graceful stop
* =====================
* Enable graceful stop
*/
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));
/**
* Router
* =====================
* Core of bot
*/
require(__dirname + '/routes/command')(bot, config);
require(__dirname + '/routes/hears')(bot, config);
require(__dirname + '/routes/inline_query')(bot, config);
/**
* Polling
* =====================
* Telegraf Socket
*/
bot.launch();