-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBot.js
More file actions
31 lines (24 loc) · 796 Bytes
/
Bot.js
File metadata and controls
31 lines (24 loc) · 796 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
import DB from './DB.js'
import Service from './Service.js'
import TelegramApi from 'node-telegram-bot-api'
class Bot {
constructor() {
this.token = process.env.TELEGRAM_TOKEN
new DB()
this.serviceCity = new Service()
this.api = new TelegramApi(this.token, {polling: true})
this.hangEvents()
}
hangEvents() {
this.api.setMyCommands(this.setCommands())
this.api.on('message', async message => {
console.log(message)
const answer = await this.serviceCity.getAnswer(message)
await this.api.sendMessage(message.chat.id, answer)
})
}
setCommands() {
return [{command: '/watch', description: 'Список доступных команд'}]
}
}
export default Bot