mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
feat: improve furry and gay commands by sending the percentage (#33)
This commit is contained in:
parent
5b78e542de
commit
ad7feeee9a
@ -3,25 +3,27 @@ const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
function sendRandomReply(ctx, gifUrl, textKey, notTextKey) {
|
||||
function sendRandomReply(ctx, gifUrl, textKey) {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
const shouldSendGif = Math.random() < 0.5;
|
||||
const randomNumber = Math.floor(Math.random() * 100);
|
||||
const shouldSendGif = randomNumber > 50;
|
||||
|
||||
const caption = Strings[textKey].replace('{randomNum}', randomNumber)
|
||||
|
||||
if (shouldSendGif) {
|
||||
ctx.replyWithAnimation(gifUrl, {
|
||||
caption: Strings[textKey],
|
||||
caption,
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
}).catch(err => {
|
||||
gifErr = gifErr.replace('{err}', err);
|
||||
|
||||
ctx.reply(Strings.gifErr, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ctx.reply(Strings[notTextKey], {
|
||||
ctx.reply(caption, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
@ -46,7 +48,7 @@ async function handleDiceCommand(ctx, emoji, delay) {
|
||||
}
|
||||
|
||||
function getRandomInt(max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
return Math.floor(Math.random() * (max + 1));
|
||||
}
|
||||
|
||||
module.exports = (bot) => {
|
||||
@ -90,11 +92,11 @@ module.exports = (bot) => {
|
||||
});
|
||||
|
||||
bot.command('furry', spamwatchMiddleware, async (ctx) => {
|
||||
sendRandomReply(ctx, Resources.furryGif, 'isFurry', 'isNtFurry');
|
||||
sendRandomReply(ctx, Resources.furryGif, 'furryAmount');
|
||||
});
|
||||
|
||||
bot.command('gay', spamwatchMiddleware, async (ctx) => {
|
||||
sendRandomReply(ctx, Resources.gayFlag, 'isGay', 'isNtGay');
|
||||
sendRandomReply(ctx, Resources.gayFlag, 'gayAmount');
|
||||
});
|
||||
|
||||
bot.command(['soggy', 'soggycat'], spamwatchMiddleware, async (ctx) => {
|
||||
|
@ -25,10 +25,8 @@
|
||||
"botNameErr": "*Error changing bot name:*\n`{tgErr}`",
|
||||
"botDescChanged": "*Bot description changed to* `{botDesc}`.",
|
||||
"botDescErr": "*Error changing bot description:*\n`{tgErr}`",
|
||||
"isGay": "Yes, you are *gay*!",
|
||||
"isNtGay": "Ah, you are not gay!",
|
||||
"isFurry": "Yes, you are *furry*!",
|
||||
"isNtFurry": "Ah, you are not a furry!",
|
||||
"gayAmount": "You are *{randomNum}%* gay!",
|
||||
"furryAmount": "You are *{randomNum}%* furry!",
|
||||
"randomNum": "*Generated number (0-10):* `{number}`.",
|
||||
"userInfo": "*User info*\n\n*Name:* `{userName}`\n*Username:* `{userHandle}`\n*User ID:* `{userId}`\n*Language:* `{userLang}`\n*Premium user:* `{userPremium}`",
|
||||
"chatInfo": "*Chat info*\n\n*Name:* `{chatName}`\n*Chat ID:* `{chatId}`\n*Handle:* `{chatHandle}`\n*Type:* `{chatType}`\n*Members:* `{chatMembersCount}`\n*Is a forum:* `{isForum}`",
|
||||
|
@ -25,10 +25,8 @@
|
||||
"botNameErr": "*Erro ao alterar o nome do bot:*\n`{tgErr}`",
|
||||
"botDescChanged": "*Descrição do bot alterada para* `{botDesc}`.",
|
||||
"botDescErr": "*Erro ao alterar a descrição do bot:*\n`{tgErr}`",
|
||||
"isGay": "Sim, você é *gay*!",
|
||||
"isNtGay": "Ah, você não é gay!",
|
||||
"isFurry": "Sim, você é *furry*!",
|
||||
"isNtFurry": "Ah, você não é furry!",
|
||||
"gayAmount": "Você é *{randomNum}%* gay!",
|
||||
"furryAmount": "Você é *{randomNum}%* furry!",
|
||||
"randomNum": "*Número gerado (0-10):* `{number}`.",
|
||||
"userInfo": "*Informações do usuário*\n\n*Nome:* `{userName}`\n*Usuário:* `{userHandle}`\n*ID:* `{userId}`\n*Idioma:* `{userLang}`\n*Usuário Premium:* `{userPremium}`",
|
||||
"chatInfo": "*Informações do chat*\n\n*Nome:* `{chatName}`\n*ID do chat:* `{chatId}`\n*Identificador:* `{chatHandle}`\n*Tipo:* `{chatType}`\n*Membros:* `{chatMembersCount}`\n*É um fórum:* `{isForum}`",
|
||||
|
Loading…
x
Reference in New Issue
Block a user