feat: improve furry and gay commands by sending the percentage

This commit is contained in:
GiovaniFZ 2025-02-15 15:37:53 -03:00
parent 5b78e542de
commit d0cbad401d
No known key found for this signature in database
GPG Key ID: 63DD92181B575322
3 changed files with 14 additions and 16 deletions

View File

@ -3,25 +3,27 @@ const { getStrings } = require('../plugins/checklang.js');
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); 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 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) { if (shouldSendGif) {
ctx.replyWithAnimation(gifUrl, { ctx.replyWithAnimation(gifUrl, {
caption: Strings[textKey], caption,
parse_mode: 'Markdown', parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id reply_to_message_id: ctx.message.message_id
}).catch(err => { }).catch(err => {
gifErr = gifErr.replace('{err}', err); gifErr = gifErr.replace('{err}', err);
ctx.reply(Strings.gifErr, { ctx.reply(Strings.gifErr, {
parse_mode: 'Markdown', parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id reply_to_message_id: ctx.message.message_id
}); });
}); });
} else { } else {
ctx.reply(Strings[notTextKey], { ctx.reply(caption, {
parse_mode: 'Markdown', parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id reply_to_message_id: ctx.message.message_id
}); });
@ -46,7 +48,7 @@ async function handleDiceCommand(ctx, emoji, delay) {
} }
function getRandomInt(max) { function getRandomInt(max) {
return Math.floor(Math.random() * max); return Math.floor(Math.random() * (max + 1));
} }
module.exports = (bot) => { module.exports = (bot) => {
@ -90,11 +92,11 @@ module.exports = (bot) => {
}); });
bot.command('furry', spamwatchMiddleware, async (ctx) => { bot.command('furry', spamwatchMiddleware, async (ctx) => {
sendRandomReply(ctx, Resources.furryGif, 'isFurry', 'isNtFurry'); sendRandomReply(ctx, Resources.furryGif, 'furryAmount');
}); });
bot.command('gay', spamwatchMiddleware, async (ctx) => { bot.command('gay', spamwatchMiddleware, async (ctx) => {
sendRandomReply(ctx, Resources.gayFlag, 'isGay', 'isNtGay'); sendRandomReply(ctx, Resources.gayFlag, 'gayAmount');
}); });
bot.command(['soggy', 'soggycat'], spamwatchMiddleware, async (ctx) => { bot.command(['soggy', 'soggycat'], spamwatchMiddleware, async (ctx) => {

View File

@ -25,10 +25,8 @@
"botNameErr": "*Error changing bot name:*\n`{tgErr}`", "botNameErr": "*Error changing bot name:*\n`{tgErr}`",
"botDescChanged": "*Bot description changed to* `{botDesc}`.", "botDescChanged": "*Bot description changed to* `{botDesc}`.",
"botDescErr": "*Error changing bot description:*\n`{tgErr}`", "botDescErr": "*Error changing bot description:*\n`{tgErr}`",
"isGay": "Yes, you are *gay*!", "gayAmount": "You are *{randomNum}%* gay!",
"isNtGay": "Ah, you are not gay!", "furryAmount": "You are *{randomNum}%* furry!",
"isFurry": "Yes, you are *furry*!",
"isNtFurry": "Ah, you are not a furry!",
"randomNum": "*Generated number (0-10):* `{number}`.", "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}`", "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}`", "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}`",

View File

@ -25,10 +25,8 @@
"botNameErr": "*Erro ao alterar o nome do bot:*\n`{tgErr}`", "botNameErr": "*Erro ao alterar o nome do bot:*\n`{tgErr}`",
"botDescChanged": "*Descrição do bot alterada para* `{botDesc}`.", "botDescChanged": "*Descrição do bot alterada para* `{botDesc}`.",
"botDescErr": "*Erro ao alterar a descrição do bot:*\n`{tgErr}`", "botDescErr": "*Erro ao alterar a descrição do bot:*\n`{tgErr}`",
"isGay": "Sim, você é *gay*!", "gayAmount": "Você é *{randomNum}%* gay!",
"isNtGay": "Ah, você não é gay!", "furryAmount": "Você é *{randomNum}%* furry!",
"isFurry": "Sim, você é *furry*!",
"isNtFurry": "Ah, você não é furry!",
"randomNum": "*Número gerado (0-10):* `{number}`.", "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}`", "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}`", "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}`",