2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-30 21:55:17 +00:00

send a message when /ban and /warn is used in private chat

This commit is contained in:
Pouria Ezzati
2017-11-02 00:18:59 +03:30
parent 8029e27fac
commit f6dfa08d4b
2 changed files with 19 additions and 12 deletions

View File

@@ -13,8 +13,6 @@ const { listGroups } = require('../../stores/group');
const { isAdmin, isBanned, ban } = require('../../stores/user');
const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
if (!state.isAdmin) return null;
const userToBan = message.reply_to_message
? message.reply_to_message.from
: message.commandMention
@@ -22,6 +20,15 @@ const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
: null;
const reason = message.text.split(' ').slice(1).join(' ').trim();
if (!state.isAdmin || userToBan.username === me) return null;
if (message.chat.type === 'private') {
return reply(
' <b>This command is only available in groups.</b>',
replyOptions
);
}
if (!userToBan) {
return reply(
' <b>Reply to a message or mention a user.</b>',
@@ -29,10 +36,6 @@ const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
).then(scheduleDeletion);
}
if (message.chat.type === 'private' || userToBan.username === me) {
return null;
}
if (await isAdmin(userToBan)) {
return reply(' <b>Can\'t ban other admins.</b>', replyOptions);
}

View File

@@ -20,14 +20,22 @@ const { isAdmin, ban, getWarns, warn } = require('../../stores/user');
const warnHandler = async ({ message, chat, reply, me, state }) => {
const { user } = state;
if (!state.isAdmin) return null;
const userToWarn = message.reply_to_message
? message.reply_to_message.from
: message.commandMention
? message.commandMention
: null;
if (!state.isAdmin || userToWarn.username === me) return null;
if (message.chat.type === 'private') {
return reply(
' <b>This command is only available in groups.</b>',
replyOptions
);
}
if (!userToWarn) {
return reply(
' <b>Reply to a message or mentoin a user.</b>',
@@ -35,10 +43,6 @@ const warnHandler = async ({ message, chat, reply, me, state }) => {
).then(scheduleDeletion);
}
if (message.chat.type === 'private' || userToWarn.username === me) {
return null;
}
const reason = message.text.split(' ').slice(1).join(' ').trim();
if (await isAdmin(userToWarn)) {