From d0cbad401dcaa9880d91bc6fc819ff53f4acd57c Mon Sep 17 00:00:00 2001 From: GiovaniFZ Date: Sat, 15 Feb 2025 15:37:53 -0300 Subject: [PATCH] feat: improve furry and gay commands by sending the percentage --- src/commands/fun.js | 18 ++++++++++-------- src/locales/english.json | 6 ++---- src/locales/portuguese.json | 6 ++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/commands/fun.js b/src/commands/fun.js index ed18910..2312177 100644 --- a/src/commands/fun.js +++ b/src/commands/fun.js @@ -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) => { diff --git a/src/locales/english.json b/src/locales/english.json index 72e35b8..0a4291b 100644 --- a/src/locales/english.json +++ b/src/locales/english.json @@ -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}`", diff --git a/src/locales/portuguese.json b/src/locales/portuguese.json index 3ffbc86..570f308 100644 --- a/src/locales/portuguese.json +++ b/src/locales/portuguese.json @@ -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}`",