forked from kodjunkie/beetube-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
33 lines (29 loc) · 1.07 KB
/
bot.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
const mongoose = require("mongoose");
const TelegramBot = require("node-telegram-bot-api");
TelegramBot.Promise = require("bluebird").config({
cancellation: true,
});
require("dotenv").config();
const env = process.env;
const config = require("./config");
const commands = require("./commands");
const handlers = require("./handlers");
const bot = new TelegramBot(env.BOT_TOKEN, config.bot);
mongoose
.connect(env.MONGODB_URI, config.mongodb)
.then(() => {
// Commands
bot.onText(/\/start/, commands.start(bot));
bot.onText(/about$/i, commands.about(bot));
bot.onText(/search$/i, commands.search(bot));
bot.onText(/settings$/i, commands.settings(bot));
bot.onText(/\/keyboard/, commands.keyboard(bot));
bot.onText(/(?<Provider>(Movie|Music|Torrent|Anime)$)/, commands.list(bot));
// Handlers
bot.on("callback_query", handlers.callbackQuery(bot));
bot.on("polling_error", handlers.botError);
bot.on("error", handlers.botError);
// Successful connection
console.log(`\u{1F41D} ${env.BOT_NAME} started successfully`);
})
.catch(error => console.error(error));