mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Beta ban system + Simple fixes on getinfo
This commit is contained in:
parent
55ecaba34b
commit
1d6e569cae
58
commands/admin.js
Normal file
58
commands/admin.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
const Config = require('../props/config.json');
|
||||||
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
|
|
||||||
|
async function collectInfo(ctx) {
|
||||||
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
|
const chatId = ctx.chat.id || Strings.unKnown;
|
||||||
|
const userId = ctx.from.id || Strings.unKnown;
|
||||||
|
const banId = parseInt(ctx.message.text.split(' ')[1], 10);
|
||||||
|
const admins = await ctx.telegram.getChatAdministrators(chatId);
|
||||||
|
const isAdmin = admins.some(admin => admin.user.id === userId);
|
||||||
|
const onCrew = Config.admins.includes(userId);
|
||||||
|
|
||||||
|
return { Strings, chatId, banId, isAdmin, onCrew };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = (bot) => {
|
||||||
|
bot.command('lynxban', async (ctx) => {
|
||||||
|
const info = await collectInfo(ctx);
|
||||||
|
const { Strings, chatId, banId, isAdmin, onCrew } = info;
|
||||||
|
|
||||||
|
if (onCrew || isAdmin) {
|
||||||
|
if (banId === NaN) {
|
||||||
|
return ctx.reply(
|
||||||
|
Strings.banInvalidId, {
|
||||||
|
parse_mode: 'Markdown',
|
||||||
|
reply_to_message_id: ctx.message.message_id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
await ctx.telegram.kickChatMember(chatId, banId);
|
||||||
|
const banReport = Strings.banSuccess.replace('{banId}', banId);
|
||||||
|
ctx.reply(
|
||||||
|
banReport, {
|
||||||
|
parse_mode: 'Markdown',
|
||||||
|
reply_to_message_id: ctx.message.message_id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
const banErr = Strings.banErr.replace('{tgErr}', err);
|
||||||
|
ctx.reply(
|
||||||
|
banErr, {
|
||||||
|
parse_mode: 'Markdown',
|
||||||
|
reply_to_message_id: ctx.message.message_id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
ctx.reply(
|
||||||
|
Strings.noPermission, {
|
||||||
|
parse_mode: 'Markdown',
|
||||||
|
reply_to_message_id: ctx.message.message_id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
@ -45,7 +45,11 @@ async function getChatInfo(ctx) {
|
|||||||
|
|
||||||
return chatInfoTemplate;
|
return chatInfoTemplate;
|
||||||
} else {
|
} else {
|
||||||
return Strings.groupOnly;
|
return ctx.reply(
|
||||||
|
Strings.groupOnly, {
|
||||||
|
parse_mode: 'Markdown',
|
||||||
|
reply_to_message_id: ctx.message.message_id
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
"botAdminOnly": "This command is exclusive to the bot's general administrators. I can't disclose who they are, nor what this command does.",
|
"botAdminOnly": "This command is exclusive to the bot's general administrators. I can't disclose who they are, nor what this command does.",
|
||||||
"privateOnly": "This command should be used only on private chats, and not on groups.",
|
"privateOnly": "This command should be used only on private chats, and not on groups.",
|
||||||
"groupOnly": "This command should be used only on groups, and not on private chats.",
|
"groupOnly": "This command should be used only on groups, and not on private chats.",
|
||||||
|
"banInvalidId": "Please enter a valid user ID.",
|
||||||
|
"banSuccess": "User with ID `{banId}` has been banned.",
|
||||||
|
"banErr": "Could not ban the user. Please check if the ID is correct and if the bot has admin permissions.\n\n{tgErr}",
|
||||||
"isGay": "Yes, you are *gay*!",
|
"isGay": "Yes, you are *gay*!",
|
||||||
"isNtGay": "Aahhh. You are not gay!",
|
"isNtGay": "Aahhh. You are not gay!",
|
||||||
"isFurry": "Yes, you are a freaky *furry*!",
|
"isFurry": "Yes, you are a freaky *furry*!",
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
"botAdminOnly": "Esse comando é exclusivo a administradores gerais do bot. Não posso informar quem são, e nem o que esse comando faz.",
|
"botAdminOnly": "Esse comando é exclusivo a administradores gerais do bot. Não posso informar quem são, e nem o que esse comando faz.",
|
||||||
"privateOnly": "Esse comando deve ser utilizado apenas em chats privados, e não em grupos.",
|
"privateOnly": "Esse comando deve ser utilizado apenas em chats privados, e não em grupos.",
|
||||||
"groupOnly": "Esse comando deve ser utilizado apenas em grupos, e não em chats privados.",
|
"groupOnly": "Esse comando deve ser utilizado apenas em grupos, e não em chats privados.",
|
||||||
|
"banInvalidId": "Por favor, insira um ID de usuário válido.",
|
||||||
|
"banSuccess": "Usuário com ID `{banId}` foi banido.",
|
||||||
|
"banErr": "Não foi possível banir o usuário. Verifique se o ID está correto e se o bot tem permissões de administrador.\n\n`{tgErr}`",
|
||||||
"isGay": "Sim, você é *gay*!",
|
"isGay": "Sim, você é *gay*!",
|
||||||
"isNtGay": "Aahhh. Você não é gay!",
|
"isNtGay": "Aahhh. Você não é gay!",
|
||||||
"isFurry": "Sim, você é um *furry* esquisito!",
|
"isFurry": "Sim, você é um *furry* esquisito!",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user