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');
|
2024-07-28 13:31:04 -03:00
|
|
|
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
|
|
|
|
2024-08-30 21:12:38 -03:00
|
|
|
function sendRandomReply(ctx, gifUrl, textKey, notTextKey) {
|
2024-07-25 23:40:22 -03:00
|
|
|
const Strings = getStrings(ctx.from.language_code);
|
2024-08-30 21:12:38 -03:00
|
|
|
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-08-30 21:12:38 -03:00
|
|
|
});
|
|
|
|
});
|
2024-07-24 22:39:27 -03:00
|
|
|
} else {
|
2024-08-30 21:12:38 -03:00
|
|
|
ctx.reply(Strings[notTextKey], {
|
|
|
|
parse_mode: 'Markdown',
|
|
|
|
reply_to_message_id: ctx.message.message_id
|
|
|
|
});
|
2024-07-24 22:39:27 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-30 21:12:38 -03:00
|
|
|
|
|
|
|
async function handleDiceCommand(ctx, emoji, delay) {
|
2024-07-25 23:40:22 -03:00
|
|
|
const Strings = getStrings(ctx.from.language_code);
|
2024-08-30 21:12:38 -03:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-08-31 21:23:30 -03:00
|
|
|
function getRandomInt(max) {
|
|
|
|
return Math.floor(Math.random() * max);
|
|
|
|
}
|
|
|
|
|
2024-07-24 22:39:27 -03:00
|
|
|
module.exports = (bot) => {
|
2024-08-31 21:23:30 -03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2024-07-28 13:31:04 -03:00
|
|
|
bot.command('dice', spamwatchMiddleware, async (ctx) => {
|
2024-08-30 21:12:38 -03:00
|
|
|
await handleDiceCommand(ctx, undefined, 4000);
|
2024-07-26 00:43:30 -03:00
|
|
|
});
|
|
|
|
|
2024-07-28 13:31:04 -03:00
|
|
|
bot.command('slot', spamwatchMiddleware, async (ctx) => {
|
2024-08-30 21:12:38 -03:00
|
|
|
await handleDiceCommand(ctx, '🎰', 3000);
|
|
|
|
});
|
|
|
|
|
|
|
|
bot.command('ball', spamwatchMiddleware, async (ctx) => {
|
|
|
|
await handleDiceCommand(ctx, '⚽', 3000);
|
|
|
|
});
|
|
|
|
|
2024-08-31 21:23:30 -03:00
|
|
|
bot.command('dart', spamwatchMiddleware, async (ctx) => {
|
|
|
|
await handleDiceCommand(ctx, '🎯', 3000);
|
|
|
|
});
|
|
|
|
|
|
|
|
bot.command('bowling', spamwatchMiddleware, async (ctx) => {
|
|
|
|
await handleDiceCommand(ctx, '🎳', 3000);
|
|
|
|
});
|
|
|
|
|
2024-08-30 21:12:38 -03:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2024-07-28 13:31:04 -03:00
|
|
|
bot.command('furry', spamwatchMiddleware, async (ctx) => {
|
2024-08-30 21:12:38 -03:00
|
|
|
sendRandomReply(ctx, resources.furryGif, 'isFurry', 'isNtFurry');
|
2024-07-24 22:39:27 -03:00
|
|
|
});
|
|
|
|
|
2024-07-28 13:31:04 -03:00
|
|
|
bot.command('gay', spamwatchMiddleware, async (ctx) => {
|
2024-08-30 21:12:38 -03:00
|
|
|
sendRandomReply(ctx, resources.gayFlag, 'isGay', 'isNtGay');
|
2024-07-24 22:39:27 -03:00
|
|
|
});
|
2024-08-30 21:12:38 -03:00
|
|
|
};
|