mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Finally randomizing cat photos but disabled GIF support
This commit is contained in:
parent
baf988b5b6
commit
16438d7457
@ -1,35 +1,58 @@
|
|||||||
const { getStrings } = require('../plugins/checklang.js');
|
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);
|
||||||
|
const axios = require('axios');
|
||||||
|
|
||||||
module.exports = (bot) => {
|
module.exports = (bot) => {
|
||||||
|
// 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}`;
|
||||||
|
|
||||||
|
// 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}`;
|
||||||
|
|
||||||
|
// 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) => {
|
bot.command("cat", spamwatchMiddleware, async (ctx) => {
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
const userInput = ctx.message.text.split(' ').slice(1).join(' ').replace(/\s+/g, '');
|
const apiUrl = "https://cataas.com/cat?json=true";
|
||||||
let request = "";
|
const response = await axios.get(apiUrl);
|
||||||
|
const data = response.data;
|
||||||
if (userInput && userInput.includes("gif")) {
|
const imageUrl = `https://cataas.com/cat/${data._id}`;
|
||||||
request = `/gif${userInput.replace("gif", "")}`;
|
|
||||||
const apiUrl = `https://cataas.com/cat${request}`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ctx.replyWithAnimation(apiUrl, {
|
await ctx.replyWithPhoto(imageUrl, {
|
||||||
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}`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await ctx.replyWithPhoto(apiUrl, {
|
|
||||||
caption: `🐱`,
|
caption: `🐱`,
|
||||||
parse_mode: 'Markdown',
|
parse_mode: 'Markdown',
|
||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
@ -40,6 +63,5 @@ module.exports = (bot) => {
|
|||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user