Fixed http.cat command + include it in help

This commit is contained in:
Lucas Gabriel 2024-10-14 13:06:21 -03:00
parent b8067bf59e
commit 1c3c91fa1a
No known key found for this signature in database
GPG key ID: D9B075FC6DC93985
5 changed files with 58 additions and 36 deletions

View file

@ -24,22 +24,6 @@ module.exports = (bot) => {
reply_to_message_id: ctx.message.message_id
});
};
} else if (userInput && userInput.includes("http")) {
request = `/${userInput.replace("http", "")}`;
const apiUrl = `https://http.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
});
};
} else {
request = userInput ? `/${userInput}` : '';
const apiUrl = `https://cataas.com/cat${request}`;
@ -58,4 +42,31 @@ module.exports = (bot) => {
};
};
});
bot.command("httpcat", spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
const userInput = ctx.message.text.split(' ').slice(1).join(' ').replace(/\s+/g, '');
if (!userInput || isNaN(userInput)) {
return ctx.reply(Strings.catImgErr, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
}
const apiUrl = `https://http.cat/${userInput}`;
try {
await ctx.replyWithPhoto(apiUrl, {
caption: `🐱 ${apiUrl}`,
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
});
}
});
};