101 lines
3.0 KiB
JavaScript
Raw Normal View History

2024-07-24 22:39:27 -03:00
const resources = require('../props/resources.json');
2024-07-25 23:57:38 -03:00
const { getStrings } = require('../plugins/checklang.js');
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
2024-07-24 22:39:27 -03:00
function sendRandomReply(ctx, gifUrl, textKey, notTextKey) {
const Strings = getStrings(ctx.from.language_code);
const shouldSendGif = Math.random() < 0.5;
if (shouldSendGif) {
ctx.replyWithAnimation(gifUrl, {
caption: Strings[textKey],
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
}).catch(err => {
gifErr = gifErr.replace('{err}', err);
ctx.reply(Strings.gifErr, {
2024-07-25 03:55:05 +00:00
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
});
2024-07-24 22:39:27 -03:00
} else {
ctx.reply(Strings[notTextKey], {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
2024-07-24 22:39:27 -03:00
}
}
async function handleDiceCommand(ctx, emoji, delay) {
const Strings = getStrings(ctx.from.language_code);
const result = await ctx.sendDice({ emoji, reply_to_message_id: ctx.message.message_id });
const botResponse = Strings.funEmojiResult
.replace('{emoji}', result.dice.emoji)
.replace('{value}', result.dice.value);
setTimeout(() => {
ctx.reply(botResponse, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
}, delay);
2024-07-24 22:39:27 -03:00
}
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
2024-07-24 22:39:27 -03:00
module.exports = (bot) => {
bot.command('random', spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
const randomValue = getRandomInt(11);
const randomVStr = Strings.randomNum.replace('{number}', randomValue);
ctx.reply(
randomVStr, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
}
);
});
bot.command('dice', spamwatchMiddleware, async (ctx) => {
await handleDiceCommand(ctx, undefined, 4000);
2024-07-26 00:43:30 -03:00
});
bot.command('slot', spamwatchMiddleware, async (ctx) => {
await handleDiceCommand(ctx, '🎰', 3000);
});
bot.command('ball', spamwatchMiddleware, async (ctx) => {
await handleDiceCommand(ctx, '⚽', 3000);
});
bot.command('dart', spamwatchMiddleware, async (ctx) => {
await handleDiceCommand(ctx, '🎯', 3000);
});
bot.command('bowling', spamwatchMiddleware, async (ctx) => {
await handleDiceCommand(ctx, '🎳', 3000);
});
bot.command('idice', spamwatchMiddleware, async (ctx) => {
const stickerId = "CAACAgQAAxkBAAJxjWbSSP-8ZNEhEpAJjQsHsGf-UuEPAAJCAAPI-uwTAAEBVWWh4ucINQQ";
ctx.replyWithSticker(stickerId, {
reply_to_message_id: ctx.message.message_id
});
2024-07-26 00:43:30 -03:00
});
bot.command('furry', spamwatchMiddleware, async (ctx) => {
sendRandomReply(ctx, resources.furryGif, 'isFurry', 'isNtFurry');
2024-07-24 22:39:27 -03:00
});
bot.command('gay', spamwatchMiddleware, async (ctx) => {
sendRandomReply(ctx, resources.gayFlag, 'isGay', 'isNtGay');
2024-07-24 22:39:27 -03:00
});
};