mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Added self-kicking method for Crew
This commit is contained in:
parent
ac11b53619
commit
0016357513
@ -1,4 +1,3 @@
|
||||
// specific commands to the crew
|
||||
const Config = require('../props/config.json');
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
@ -63,18 +62,24 @@ module.exports = (bot) => {
|
||||
const userId = ctx.from.id || Strings.unKnown;
|
||||
if (Config.admins.includes(userId)) {
|
||||
const botName = ctx.message.text.split(' ').slice(1).join(' ');
|
||||
const botNameReport = Strings.botNameChanged.replace('{botName}', botName);
|
||||
ctx.telegram.setMyName(botName).catch(error => ctx.reply(
|
||||
"Error when changing bot name:\n" + error, {
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
}
|
||||
));
|
||||
const botNameReport = Strings.botNameChanged ? Strings.botNameChanged.replace('{botName}', botName) : `Bot name changed to ${botName}`;
|
||||
try {
|
||||
await ctx.telegram.setMyName(botName);
|
||||
ctx.reply(
|
||||
botNameReport, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
const botNameErr = Strings.botNameErr ? Strings.botNameErr.replace('{tgErr}', error.message) : `Error setting bot name: ${error.message}`;
|
||||
ctx.reply(
|
||||
botNameErr, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ctx.reply(Strings.botAdminOnly, {
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
@ -87,18 +92,24 @@ module.exports = (bot) => {
|
||||
const userId = ctx.from.id || Strings.unKnown;
|
||||
if (Config.admins.includes(userId)) {
|
||||
const botDesc = ctx.message.text.split(' ').slice(1).join(' ');
|
||||
const botDescReport = Strings.botDescChanged.replace('{botDesc}', botDesc);
|
||||
ctx.telegram.setMyDescription(botDesc).catch(error => ctx.reply(
|
||||
"Error when changing bot description:\n" + error, {
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
}
|
||||
));
|
||||
const botDescReport = Strings.botDescChanged ? Strings.botDescChanged.replace('{botDesc}', botDesc) : `Bot description changed to ${botDesc}`;
|
||||
try {
|
||||
await ctx.telegram.setMyDescription(botDesc);
|
||||
ctx.reply(
|
||||
botDescReport, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
const botDescErr = Strings.botDescErr ? Strings.botDescErr.replace('{tgErr}', error.message) : `Error setting bot description: ${error.message}`;
|
||||
ctx.reply(
|
||||
botDescErr, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ctx.reply(
|
||||
Strings.botAdminOnly, {
|
||||
@ -106,4 +117,15 @@ module.exports = (bot) => {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
bot.command('botkickme', spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
const chatId = ctx.chat.id || Strings.unKnown;
|
||||
ctx.reply(
|
||||
Strings.kickingMyself, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
ctx.telegram.leaveChat(chatId);
|
||||
});
|
||||
};
|
@ -6,12 +6,15 @@
|
||||
"varYes": "Yes",
|
||||
"varNo": "No",
|
||||
"varNone": "None",
|
||||
"kickingMyself": "*Since you don't need me, I'll get out of here.*",
|
||||
"noPermission": "You don't have permissions to run this command.",
|
||||
"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.",
|
||||
"groupOnly": "This command should be used only on groups, and not on private chats.",
|
||||
"botNameChanged": "*Bot name changed to* `{botName}`",
|
||||
"botNameErr": "*Error when changing bot name:*\n\n{tgErr}",
|
||||
"botDescChanged": "*Bot description changed to* `{botDesc}`",
|
||||
"botDescErr": "*Error when changing bot description:*\n\n{tgErr}",
|
||||
"invalidId": "Please enter a valid user ID.",
|
||||
"banSuccess": "User with ID `{userId}` 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}",
|
||||
|
@ -6,6 +6,7 @@
|
||||
"varYes": "Sim",
|
||||
"varNo": "Não",
|
||||
"varNone": "Nenhum",
|
||||
"kickingMyself": "*Já que você não precisa de mim, vou ir embora.*",
|
||||
"noPermission": "Você não tem permissões para rodar esse comando.",
|
||||
"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.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user