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

50 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-07-24 17:12:38 +02:00
'use strict';
2017-09-21 13:57:49 +04:30
require('dotenv').config();
2017-07-24 17:12:38 +02:00
// Utils
2017-09-21 13:57:49 +04:30
const { deleteAfter } = require('./utils/tg');
// Bot
const bot = require('./bot');
bot.telegram.getMe().then((botInfo) => {
bot.options.username = botInfo.username;
});
// Middleware Handlers
const leaveUnmanagedHandler = require('./handlers/middlewares/leaveUnmanaged');
const middlewareHandler = require('./handlers/middlewares/middleware');
2017-09-23 21:52:58 +03:30
const removeLinksHandler = require('./handlers/middlewares/removeLinks');
const antibotHandler = require('./handlers/middlewares/antibot');
const addedToGroupHandler = require('./handlers/middlewares/addedToGroup');
// Commmands Handlers
const adminHandler = require('./handlers/commands/admin');
const unAdminHandler = require('./handlers/commands/unadmin');
const warnHandler = require('./handlers/commands/warn');
const unwarnHandler = require('./handlers/commands/unwarn');
const nowarnsHandler = require('./handlers/commands/nowarns');
const getWarnsHandler = require('./handlers/commands/getwarns');
const banHandler = require('./handlers/commands/ban');
const unbanHandler = require('./handlers/commands/unban');
const reportHandler = require('./handlers/commands/report');
2017-09-21 13:57:49 +04:30
bot.use(leaveUnmanagedHandler);
2017-09-21 13:57:49 +04:30
bot.use(middlewareHandler);
2017-09-23 21:52:58 +03:30
bot.on('message', removeLinksHandler);
bot.on('new_chat_members', addedToGroupHandler);
bot.on('new_chat_members', antibotHandler);
bot.on([ 'new_chat_members', 'left_chat_member' ], deleteAfter(10 * 60 * 1000));
2017-09-21 13:57:49 +04:30
bot.command('admin', adminHandler);
bot.command('unadmin', unAdminHandler);
2017-09-21 13:57:49 +04:30
bot.command('warn', warnHandler);
bot.command('unwarn', unwarnHandler);
2017-09-21 23:47:26 +04:30
bot.command('nowarns', nowarnsHandler);
bot.command('getwarns', getWarnsHandler);
bot.command('ban', banHandler);
bot.command('unban', unbanHandler);
2017-09-23 20:57:32 +02:00
bot.command('report', reportHandler);
bot.hears(/^@admins?$/i, reportHandler);
2017-07-24 18:08:31 +02:00
2017-07-24 17:12:38 +02:00
bot.startPolling();