-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (27 loc) · 1008 Bytes
/
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
console.log(`BOT START`)
const config = require('./services/config').mountConfig();
const { enterMessage, dropTemp, createRaffle, callbackMiddleware, listRaffles, deleteMessage, finishMessage, start } = require('./services/telegram');
const { Telegraf } = require('telegraf')
const session = require('telegraf/session')
const Stage = require('telegraf/stage')
const Scene = require('telegraf/scenes/base');
const raffle = new Scene('raffle')
raffle.enter(enterMessage)
raffle.command('exit',dropTemp)
raffle.on('message',createRaffle)
const stage = new Stage()
stage.register(raffle)
const bot = new Telegraf(config.bot.id)
bot.use(session())
bot.use(stage.middleware())
bot.command('create', (ctx) => ctx.scene.enter('raffle'));
bot.command('finish', finishMessage);
bot.command('list', listRaffles);
bot.command('delete', deleteMessage)
bot.command('start', start);
// bot.on('message',(ctx) => {
// ctx.update
// console.log()
// })
bot.on('callback_query', callbackMiddleware);
bot.launch()