/cat command + spanish support + better language handling
This commit is contained in:
parent
0ba6f50d6f
commit
b4ed01e01f
5 changed files with 138 additions and 5 deletions
43
commands/cat.js
Normal file
43
commands/cat.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command("cat", spamwatchMiddleware, async (ctx) => {
|
||||
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: apiUrl,
|
||||
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: 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
|
||||
});
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue