mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-01 22:55:24 +00:00
Notify unbanned people
This commit is contained in:
@@ -12,6 +12,8 @@ const { listGroups } = require('../../stores/groups');
|
|||||||
const { isBanned, unban } = require('../../stores/ban');
|
const { isBanned, unban } = require('../../stores/ban');
|
||||||
const admins = require('../../stores/admin');
|
const admins = require('../../stores/admin');
|
||||||
|
|
||||||
|
const noop = Function.prototype;
|
||||||
|
|
||||||
const unbanHandler = async ({ message, reply, telegram }) => {
|
const unbanHandler = async ({ message, reply, telegram }) => {
|
||||||
if (!await admins.isAdmin(message.from)) {
|
if (!await admins.isAdmin(message.from)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -44,6 +46,15 @@ const unbanHandler = async ({ message, reply, telegram }) => {
|
|||||||
logError(process.env.DEBUG)(err);
|
logError(process.env.DEBUG)(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
telegram.sendMessage(
|
||||||
|
userToUnban.id,
|
||||||
|
'♻️ You were unbanned from all of the /groups!'
|
||||||
|
).catch(noop);
|
||||||
|
// it's likely that the banned person haven't PMed the bot,
|
||||||
|
// which will cause the sendMessage to fail,
|
||||||
|
// hance .catch(noop)
|
||||||
|
// (it's an expected, non-critical failure)
|
||||||
|
|
||||||
return reply(`♻️ ${link(message.from)} <b>unbanned</b> ` +
|
return reply(`♻️ ${link(message.from)} <b>unbanned</b> ` +
|
||||||
`${link(userToUnban)}.`, replyOptions);
|
`${link(userToUnban)}.`, replyOptions);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user