2017-09-21 13:57:49 +04:30
|
|
|
'use strict';
|
|
|
|
|
2020-09-06 14:14:24 +02:00
|
|
|
const ms = require('millisecond');
|
|
|
|
const { Telegraf } = require('telegraf');
|
2020-03-09 23:27:19 +01:00
|
|
|
const { config } = require('../utils/config');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
2020-03-10 22:10:48 +01:00
|
|
|
/** @typedef { import('../typings/context').ExtendedContext } ExtendedContext */
|
|
|
|
|
2020-09-06 14:14:24 +02:00
|
|
|
/** @type { Telegraf<ExtendedContext> } */
|
|
|
|
const bot = new Telegraf(config.token, {
|
|
|
|
handlerTimeout: ms('5s'),
|
|
|
|
telegram: { webhookReply: false },
|
|
|
|
});
|
2017-09-21 13:57:49 +04:30
|
|
|
|
2020-06-15 15:38:03 +02:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
bot.polling.offset = -1;
|
|
|
|
}
|
2017-11-01 20:59:27 +01:00
|
|
|
|
2017-09-21 13:57:49 +04:30
|
|
|
module.exports = bot;
|
2018-05-05 20:10:22 +02:00
|
|
|
|
|
|
|
// cyclic dependency
|
|
|
|
// bot/index requires context requires actions/warn requires bot/index
|
|
|
|
Object.assign(bot.context, require('./context'));
|