2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 14:15:25 +00:00

/unadmin attempts to revoke admin permissions in all groups

This commit is contained in:
GingerPlusPlus
2018-02-17 22:03:46 +01:00
parent feba5c1f43
commit eb83119492

View File

@@ -6,9 +6,26 @@ const { logError } = require('../../utils/log');
// Bot // Bot
const { replyOptions } = require('../../bot/options'); const { replyOptions } = require('../../bot/options');
const { telegram } = require('../../bot');
// DB // DB
const { isAdmin, unadmin } = require('../../stores/user'); const { isAdmin, unadmin } = require('../../stores/user');
const { listGroups } = require('../../stores/group');
const noop = Function.prototype;
const tgUnadmin = async (userToUnadmin) => {
for (const group of await listGroups()) {
telegram.promoteChatMember(group.id, userToUnadmin.id, {
can_change_info: false,
can_delete_messages: false,
can_invite_users: false,
can_pin_messages: false,
can_promote_members: false,
can_restrict_members: false,
}).catch(noop);
}
};
const unAdminHandler = async ({ message, reply, state }) => { const unAdminHandler = async ({ message, reply, state }) => {
const { isMaster } = state; const { isMaster } = state;
@@ -34,6 +51,8 @@ const unAdminHandler = async ({ message, reply, state }) => {
); );
} }
tgUnadmin(userToUnadmin);
try { try {
await unadmin(userToUnadmin); await unadmin(userToUnadmin);
} catch (err) { } catch (err) {