mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-21 02:03:57 +00:00
fix(telegram-bot): check for admin first
This commit is contained in:
@@ -1,6 +1,15 @@
|
|||||||
export default {
|
export default {
|
||||||
command: /\/train/,
|
command: /\/train/,
|
||||||
async execute(bot, config, msg) {
|
async execute(bot, config, msg) {
|
||||||
|
const admins = await bot.getChatAdministrators(msg.chat.id);
|
||||||
|
const isAdmin = admins.find((admin) => admin.user.id === msg.from.id);
|
||||||
|
|
||||||
|
if (!isAdmin)
|
||||||
|
return bot.sendMessage(msg.chat.id, 'You\'re not an admin.', {
|
||||||
|
message_thread_id: msg.message_thread_id,
|
||||||
|
reply_to_message_id: msg.message_id
|
||||||
|
});
|
||||||
|
|
||||||
if (msg.reply_to_message.message_id === msg.message_thread_id)
|
if (msg.reply_to_message.message_id === msg.message_thread_id)
|
||||||
return bot.sendMessage(msg.chat.id, 'Please reply to a message!', {
|
return bot.sendMessage(msg.chat.id, 'Please reply to a message!', {
|
||||||
message_thread_id: msg.message_thread_id,
|
message_thread_id: msg.message_thread_id,
|
||||||
@@ -37,14 +46,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const admins = await bot.getChatAdministrators(msg.chat.id);
|
|
||||||
const isAdmin = admins.find((admin) => admin.user.id === msg.from.id);
|
|
||||||
|
|
||||||
if (!isAdmin)
|
|
||||||
return bot.sendMessage(msg.chat.id, 'You\'re not an admin.', {
|
|
||||||
message_thread_id: msg.message_thread_id,
|
|
||||||
reply_to_message_id: msg.message_id
|
|
||||||
});
|
|
||||||
bot.sendMessage(
|
bot.sendMessage(
|
||||||
msg.chat.id,
|
msg.chat.id,
|
||||||
'Please select the corresponding label to train the bot.',
|
'Please select the corresponding label to train the bot.',
|
||||||
|
|||||||
Reference in New Issue
Block a user