Add random dog image

This commit is contained in:
Lucas Gabriel 2024-10-13 23:16:52 -03:00
parent aed36a1e9b
commit 0264c120d7
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985
4 changed files with 32 additions and 3 deletions

26
commands/dog.js Normal file
View File

@ -0,0 +1,26 @@
const { getStrings } = require('../plugins/checklang.js');
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
const axios = require('axios');
module.exports = (bot) => {
bot.command("dog", spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
const apiUrl = "https://dog.ceo/api/breeds/image/random";
const response = await axios.get(apiUrl);
const data = response.data;
try {
await ctx.replyWithPhoto(data.message, {
caption: `🐶`,
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
} catch (error) {
ctx.reply(Strings.dogImgErr, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
};
});
};

View File

@ -74,5 +74,6 @@
"catImgErr": "Sorry, but I couldn't get the cat photo you wanted.",
"catGifErr": "Sorry, but I couldn't get the cat GIF you wanted.",
"quoteResult": "Here is a random quote for you:",
"quoteErr": "Sorry, but something went wrong while displaying the quote."
"quoteErr": "Sorry, but something went wrong while displaying the quote.",
"dogImgErr": "Sorry, but I couldn't get the dog photo you wanted."
}

View File

@ -74,5 +74,6 @@
"catImgErr": "Desculpe, mas não consegui obter a foto do gato que você queria.",
"catGifErr": "Desculpe, mas não consegui obter o GIF do gato que você queria.",
"quoteResult": "Aqui está uma citação aleatória pra você (em inglês):",
"quoteErr": "Desculpe, mas algo deu errado ao exibir a citação."
"quoteErr": "Desculpe, mas algo deu errado ao exibir a citação.",
"dogImgErr": "Desculpe, mas não consegui obter a foto do cacbhorro que você queria."
}

View File

@ -74,5 +74,6 @@
"catImgErr": "Lo siento, pero no pude obtener la foto del gato que querías.",
"catGifErr": "Lo siento, pero no pude obtener el GIF del gato que querías.",
"quoteResult": "Aquí tienes una cita aleatoria para ti (en inglés):",
"quoteErr": "Lo siento, pero algo salió mal al mostrar la cita."
"quoteErr": "Lo siento, pero algo salió mal al mostrar la cita.",
"dogImgErr": "Lo siento, pero no pude obtener la foto del perro que querías."
}