2019-02-19 14:21:58 +01:00
|
|
|
const Telebot = require('telebot');
|
|
|
|
const config = require('./config');
|
2019-02-19 14:57:47 +01:00
|
|
|
const utils = require('./utils');
|
2019-02-20 14:31:23 +01:00
|
|
|
const auth = require('./auth');
|
2019-02-19 14:21:58 +01:00
|
|
|
|
|
|
|
const bot = new Telebot({
|
|
|
|
token: config.app.tokenBot,
|
|
|
|
usePlugins: ['askUser'],
|
|
|
|
});
|
|
|
|
|
2019-02-20 14:31:23 +01:00
|
|
|
bot.on('/*', (msg) => {
|
|
|
|
bot.sendMessage(msg.from.id, 'qualsiasi');
|
|
|
|
});
|
2019-02-19 14:21:58 +01:00
|
|
|
|
|
|
|
bot.on('/start', (msg) => {
|
2019-02-20 14:31:23 +01:00
|
|
|
auth(msg.from.id, () => {
|
|
|
|
bot.sendMessage(msg.from.id, utils.templateStart(), { parseMode: 'Markdown' });
|
|
|
|
bot.event('/help', msg);
|
|
|
|
},
|
|
|
|
() => bot.sendMessage(msg.from.id, utils.templateUnauthorizedUser(), { parseMode: 'Markdown' }));
|
2019-02-19 14:21:58 +01:00
|
|
|
});
|
|
|
|
|
2019-02-19 14:29:57 +01:00
|
|
|
bot.on('/help', (msg) => {
|
2019-02-20 14:31:23 +01:00
|
|
|
auth(msg.from.id, () => {
|
|
|
|
bot.sendMessage(msg.from.id, utils.templateHelp(), { parseMode: 'Markdown' });
|
|
|
|
});
|
2019-02-19 14:29:57 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
bot.on('/list', (msg) => {
|
2019-02-20 14:31:23 +01:00
|
|
|
auth(msg.from.id, () => {
|
|
|
|
bot.sendMessage(msg.from.id, 'list template');
|
|
|
|
});
|
2019-02-19 14:29:57 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
bot.on('/position', (msg) => {
|
2019-02-20 14:31:23 +01:00
|
|
|
auth(msg.from.id, () => {
|
|
|
|
bot.sendMessage(msg.from.id, 'position template');
|
|
|
|
});
|
2019-02-19 14:29:57 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
bot.on('/add', (msg) => {
|
2019-02-20 14:31:23 +01:00
|
|
|
auth(msg.from.id, () => {
|
|
|
|
bot.sendMessage(msg.from.id, 'add');
|
|
|
|
});
|
2019-02-19 14:29:57 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
bot.on('/remove', (msg) => {
|
2019-02-20 14:31:23 +01:00
|
|
|
auth(msg.from.id, () => {
|
|
|
|
bot.sendMessage(msg.from.id, 'remove');
|
|
|
|
});
|
2019-02-19 14:29:57 +01:00
|
|
|
});
|
|
|
|
|
2019-02-19 14:21:58 +01:00
|
|
|
|
|
|
|
bot.start();
|