2024-10-03 22:22:50 -03:00
|
|
|
const { getStrings } = require('../plugins/checklang.js');
|
2024-10-03 22:10:50 -03:00
|
|
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
|
|
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
2024-11-21 12:26:23 -03:00
|
|
|
const axios = require('axios');
|
2024-10-03 22:10:50 -03:00
|
|
|
|
|
|
|
module.exports = (bot) => {
|
2024-11-21 12:26:23 -03:00
|
|
|
// bot.command("cat", spamwatchMiddleware, async (ctx) => {
|
|
|
|
// const Strings = getStrings(ctx.from.language_code);
|
|
|
|
// const userInput = ctx.message.text.split(' ').slice(1).join(' ').replace(/\s+/g, '');
|
|
|
|
// let request = "";
|
|
|
|
|
|
|
|
// if (userInput && userInput.includes("gif")) {
|
|
|
|
// request = `/gif${userInput.replace("gif", "")}`;
|
|
|
|
// const apiUrl = `https://cataas.com/cat${request}`;
|
2024-10-03 22:10:50 -03:00
|
|
|
|
2024-11-21 12:26:23 -03:00
|
|
|
// try {
|
|
|
|
// await ctx.replyWithAnimation(apiUrl, {
|
|
|
|
// caption: `🐱`,
|
|
|
|
// parse_mode: 'Markdown',
|
|
|
|
// reply_to_message_id: ctx.message.message_id
|
|
|
|
// });
|
|
|
|
// } catch (error) {
|
|
|
|
// ctx.reply(Strings.catGifErr, {
|
|
|
|
// parse_mode: 'Markdown',
|
|
|
|
// reply_to_message_id: ctx.message.message_id
|
|
|
|
// });
|
|
|
|
// };
|
|
|
|
// } else {
|
|
|
|
// request = userInput ? `/${userInput}` : '';
|
|
|
|
// const apiUrl = `https://cataas.com/cat${request}`;
|
2024-10-03 22:10:50 -03:00
|
|
|
|
2024-11-21 12:26:23 -03:00
|
|
|
// try {
|
|
|
|
// await ctx.replyWithPhoto(apiUrl, {
|
|
|
|
// caption: `🐱`,
|
|
|
|
// parse_mode: 'Markdown',
|
|
|
|
// reply_to_message_id: ctx.message.message_id
|
|
|
|
// });
|
|
|
|
// } catch (error) {
|
|
|
|
// ctx.reply(Strings.catImgErr, {
|
|
|
|
// parse_mode: 'Markdown',
|
|
|
|
// reply_to_message_id: ctx.message.message_id
|
|
|
|
// });
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
// });
|
|
|
|
|
|
|
|
bot.command("cat", spamwatchMiddleware, async (ctx) => {
|
|
|
|
const Strings = getStrings(ctx.from.language_code);
|
|
|
|
const apiUrl = "https://cataas.com/cat?json=true";
|
|
|
|
const response = await axios.get(apiUrl);
|
|
|
|
const data = response.data;
|
|
|
|
const imageUrl = `https://cataas.com/cat/${data._id}`;
|
2024-10-03 22:10:50 -03:00
|
|
|
|
2024-11-21 12:26:23 -03:00
|
|
|
try {
|
|
|
|
await ctx.replyWithPhoto(imageUrl, {
|
|
|
|
caption: `🐱`,
|
|
|
|
parse_mode: 'Markdown',
|
|
|
|
reply_to_message_id: ctx.message.message_id
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
ctx.reply(Strings.catImgErr, {
|
|
|
|
parse_mode: 'Markdown',
|
|
|
|
reply_to_message_id: ctx.message.message_id
|
|
|
|
});
|
2024-10-03 22:10:50 -03:00
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|