2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 06:05:22 +00:00
This commit is contained in:
Thomas Rory Gummerson
2017-07-24 19:17:13 +02:00
parent f7d2455cb1
commit b9b17b46f2

View File

@@ -1,6 +1,6 @@
'use strict';
const DEBUG = true;
const DEBUG = false;
// validate config
require('child_process').execSync('node init.js', { stdio: 'inherit' });
@@ -41,7 +41,19 @@ bot.command('admin', async ({ message, reply }) => {
reply('Admined ' + link(userToAdmin), replyOptions));
});
bot.on('new_chat_member', deleteAfter(10 * 60 * 1000));
bot.on('new_chat_member', ctx => {
if (
ctx.new_chat_member.username &&
ctx.new_chat_member.username.substr(-3).toLowerCase() === 'bot'
) {
return ctx.telegram.kickChatMember(ctx.chat.id, ctx.new_chat_member.id)
.then(() => ctx.telegram.deleteMessage(ctx.message.message_id))
.then(() => ctx.reply(`Kicked bot: ${link(ctx.new_chat_member)}`))
.catch(logError(DEBUG));
}
return deleteAfter(10 * 60 * 1000)(ctx);
});
bot.on('left_chat_member', deleteAfter(10 * 60 * 1000));
bot.use(async (ctx, next) => {