mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-22 18:08:51 +00:00
29 lines
812 B
JavaScript
29 lines
812 B
JavaScript
'use strict';
|
|
|
|
const ms = require('millisecond');
|
|
const { Telegraf } = require('telegraf');
|
|
const { config } = require('../utils/config');
|
|
|
|
/** @typedef { import('../typings/context').ExtendedContext } ExtendedContext */
|
|
|
|
/** @type { Telegraf<ExtendedContext> } */
|
|
const bot = new Telegraf(config.token, {
|
|
handlerTimeout: ms('5s'),
|
|
telegram: { webhookReply: false },
|
|
});
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
bot.polling.offset = -1;
|
|
}
|
|
|
|
module.exports = bot;
|
|
|
|
// Otherwise the bot can't ban on reaching max warns due to botInfo not being available to get its admin ID
|
|
Object.defineProperty(bot.context, "botInfo", {
|
|
get () { return bot.botInfo; }
|
|
})
|
|
|
|
// cyclic dependency
|
|
// bot/index requires context requires actions/warn requires bot/index
|
|
Object.assign(bot.context, require('./context').extn);
|