-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (26 loc) · 665 Bytes
/
index.js
File metadata and controls
33 lines (26 loc) · 665 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
33
const { config } = require('./config')
const commands = require('./commands')
const express = require('express')
const Telegraf = require('telegraf')
const app = express()
const bot = new Telegraf(config.botToken, {
telegram: {
webhookReply: false
}
})
commands.configure(bot)
app.use(bot.webhookCallback('/callback'))
app.get('/', (req, res) => {
res.send('ok')
})
app.get('/start', async (req, res) => {
const url = `${config.currentHost}/callback`
await bot.telegram.setWebhook(url)
res.send(url)
})
if (config.isDevelopment) {
console.log('listening local')
bot.launch()
}
app.listen(3000, () =>
console.log('app running on 3000'))