2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-23 10:28:09 +00:00
the-guard-bot/bot/index.js

29 lines
807 B
JavaScript
Raw Normal View History

2017-09-21 13:57:49 +04:30
'use strict';
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 */
/** @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-09-21 13:57:49 +04:30
module.exports = bot;
2018-05-05 20:10:22 +02:00
// Elsewhere the bot can't ban on reaching max warns due to botInfo not being available to get its admin ID
2021-05-08 22:28:42 +02:00
Object.defineProperty(bot.context, "botInfo", {
get () { return bot.botInfo; }
})
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'));