2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 06:05:22 +00:00

Notify unbanned people

This commit is contained in:
GingerPlusPlus
2017-09-24 22:42:39 +02:00
parent 49397a16f7
commit 36706e7a5d

View File

@@ -12,6 +12,8 @@ const { listGroups } = require('../../stores/groups');
const { isBanned, unban } = require('../../stores/ban');
const admins = require('../../stores/admin');
const noop = Function.prototype;
const unbanHandler = async ({ message, reply, telegram }) => {
if (!await admins.isAdmin(message.from)) {
return null;
@@ -44,6 +46,15 @@ const unbanHandler = async ({ message, reply, telegram }) => {
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> ` +
`${link(userToUnban)}.`, replyOptions);
};