2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-10-09 13:55:52 +00:00

Upgrade to Telegraf 4.3

This commit is contained in:
Martin Rys
2021-05-07 22:46:11 +02:00
parent a71292a700
commit 96e6a3c761
15 changed files with 59 additions and 56 deletions

View File

@@ -13,41 +13,41 @@ const {
} = require('../../stores/user');
/** @param { import('../../typings/context').ExtendedContext } ctx */
const adminHandler = async ({ from, message, replyWithHTML }) => {
if (!isMaster(from)) return null;
const adminHandler = async (ctx) => {
if (!isMaster(ctx.from)) return null;
const { targets } = parse(message);
const { targets } = parse(ctx.message);
if (targets.length > 1) {
return replyWithHTML(
return ctx.replyWithHTML(
' <b>Specify one user to promote.</b>',
).then(scheduleDeletion());
}
const userToAdmin = targets.length
? await getUser(strip(targets[0]))
: from;
: ctx.from;
if (!userToAdmin) {
return replyWithHTML(
return ctx.replyWithHTML(
'❓ <b>User unknown.</b>\n' +
'Please forward their message, then try again.',
).then(scheduleDeletion());
}
if (userToAdmin.status === 'banned') {
return replyWithHTML(' <b>Can\'t admin banned user.</b>');
return ctx.replyWithHTML(' <b>Can\'t admin banned user.</b>');
}
if (userToAdmin.status === 'admin') {
return replyWithHTML(
return ctx.replyWithHTML(
html`⭐️ ${link(userToAdmin)} <b>is already admin.</b>`,
);
}
await admin(userToAdmin);
return replyWithHTML(html`⭐️ ${link(userToAdmin)} <b>is now admin.</b>`);
return ctx.replyWithHTML(html`⭐️ ${link(userToAdmin)} <b>is now admin.</b>`);
};
module.exports = adminHandler;