-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
69 lines (57 loc) · 2.04 KB
/
index.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const { Telegraf } = require('telegraf');
const dotenv = require('dotenv').config()
const connectDB = require("./config/db");
const { HelpMsg, joinBot,aboutBot, aboutOmniflix } = require('./src/template');
const { subscribeCMD } = require('./src/subscribe');
const { unSubscribeCMD } = require('./src/unsubscribe');
// uncomment this to fetch data
const { mainSchedulerData } = require('./src/mainJobScheduler');
const { activityFetch } = require('./src/activityFetching');
connectDB()
const bot = new Telegraf(process.env.token);
bot.command('about',async (ctx) =>{
console.time(`Processing update ${ctx.update.message.update_id}`);
await ctx.reply(aboutBot)
console.timeEnd(`Processing update ${ctx.update.message.update_id}`);
})
bot.command('omniflix',async (ctx) =>{
console.time(`Processing update ${ctx.update.message.update_id}`);
await ctx.reply(aboutOmniflix)
console.timeEnd(`Processing update ${ctx.update.message.update_id}`);
})
bot.command('join',async (ctx) =>{
console.time(`Processing update ${ctx.update.message.update_id}`);
await ctx.reply(joinBot)
console.timeEnd(`Processing update ${ctx.update.message.update_id}`);
})
bot.command('help',async (ctx) =>{
console.time(`Processing update ${ctx.update.message.update_id}`);
await ctx.reply(HelpMsg)
console.timeEnd(`Processing update ${ctx.update.message.update_id}`);
})
bot.command('subscribe',subscribeCMD);
bot.command('unsubscribe',unSubscribeCMD)
bot.launch();
console.log("App is running")
// Enable graceful stop
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));
// sample message
// message: {
// message_id: 31,
// from: {
// id: 900794755,
// is_bot: false,
// first_name: 'BlockEater',
// username: 'BlockEater'
// },
// chat: {
// id: -837257700,
// title: 'TELEGRAM-bot demo-group',
// type: 'group',
// all_members_are_administrators: true
// },
// date: 1669728465,
// text: '/text',
// entities: [ [Object] ]
// }