mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-29 21:27:47 +00:00
parent
ed4473fbab
commit
7143e588a6
@ -1,29 +1,28 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const dedent = require('dedent-js');
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
const { link } = require('../../utils/tg');
|
const { link } = require('../../utils/tg');
|
||||||
const { logError } = require('../../utils/log');
|
|
||||||
|
|
||||||
// Bot
|
|
||||||
const bot = require('../../bot');
|
|
||||||
const { replyOptions } = require('../../bot/options');
|
const { replyOptions } = require('../../bot/options');
|
||||||
|
|
||||||
// DB
|
const kickBannedHandler = async (ctx, next) => {
|
||||||
const { isBanned } = require('../../stores/user');
|
if (ctx.chat.type === 'private') {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
if (ctx.from.status === 'banned') {
|
||||||
|
ctx.deleteMessage();
|
||||||
|
await ctx.kickChatMember(ctx.from.id);
|
||||||
|
return ctx.replyWithHTML(
|
||||||
|
dedent(`
|
||||||
|
🚫 ${link(ctx.from)} <b>is banned</b>!
|
||||||
|
|
||||||
const kickbanned = async ({ chat, from, reply }, next) => {
|
Reason: ${ctx.from.ban_reason}`),
|
||||||
const banned = await isBanned(from);
|
|
||||||
if (banned) {
|
|
||||||
return bot.telegram.kickChatMember(chat.id, from.id)
|
|
||||||
.then(() => reply(
|
|
||||||
`🚫 ${link(from)} <b>is banned</b>!\n\n` +
|
|
||||||
`Reason: ${banned}`,
|
|
||||||
replyOptions
|
replyOptions
|
||||||
))
|
);
|
||||||
.catch(logError)
|
|
||||||
.then(next);
|
|
||||||
}
|
}
|
||||||
return next();
|
return next();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = kickbanned;
|
module.exports = kickBannedHandler;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user