forked from GedionT/Amharic-corps-collector-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (60 loc) · 1.59 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
70
require('dotenv').config();
const {
Telegraf,
session,
Scenes: { Stage, WizardScene },
} = require('telegraf');
const { keyboard } = require('./utils/utils');
const bot = new Telegraf(process.env.BOT_TOKEN);
const {
finished,
voiceHandler,
re_recordVoice,
sendVoice,
counter,
startDonateHandler,
Diction,
} = require('./scene/DonateScene');
const DonateScene = new WizardScene(
'DonateVoice',
counter,
startDonateHandler,
voiceHandler,
sendVoice,
re_recordVoice,
finished,
Diction
);
const stage = new Stage([DonateScene]);
stage.hears('exit', (ctx) => ctx.scene.leave());
bot.use(session(), stage.middleware());
bot.command('/start', (ctx) =>
ctx.reply('Welcome To Lesan Amharic Data Corpus Sourcer', keyboard)
);
bot.hears('Donate', (ctx) => ctx.scene.enter('DonateVoice'));
bot.hears('Verify', (ctx) =>
ctx.reply(
'This feature will be functional when enough amount of data is collected. Please keep Donating your voice, Thank You!',
keyboard
)
);
bot.hears('About Us', (ctx) => {
ctx.reply(
"This is a project built on top of Dawud's data collection bot, to ease the process of data collection for Lesan.Studio project",
keyboard
);
});
bot.hears('Statistics', (ctx) => {
ctx.reply(
'As the project progresses, current stats will start to show up here. Hang tight :)',
keyboard
);
});
bot.command('/info', (ctx) => ctx.scene.enter('infoScene'));
bot.launch();
bot.catch((err) => {
console.log('Ooops', err);
});
// Enable graceful stop
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));