Random duck image

This commit is contained in:
Lucas Gabriel 2025-02-08 20:57:15 -03:00
parent f01feb7468
commit f8c54da5a2
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985
4 changed files with 29 additions and 1 deletions

25
src/commands/duck.js Normal file
View File

@ -0,0 +1,25 @@
const Resources = require('../props/resources.json');
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("duck", spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
try {
const response = await axios(Resources.duckApi);
ctx.replyWithPhoto(response.data.url, {
caption: response.data.message,
reply_to_message_id: ctx.message.message_id
});
} catch (error) {
const message = Strings.duckApiErr.replace('{error}', error.message);
ctx.reply(message, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
return;
}
});
}

View File

@ -87,6 +87,7 @@
"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.", "dogImgErr": "Sorry, but I couldn't get the dog photo you wanted.",
"foxApiErr": "An error occurred while fetching data from the API.\n\n`{error}`", "foxApiErr": "An error occurred while fetching data from the API.\n\n`{error}`",
"duckApiErr": "An error occurred while fetching data from the API.\n\n`{error}`",
"httpCodes": { "httpCodes": {
"invalidCode": "Please enter a valid HTTP code.", "invalidCode": "Please enter a valid HTTP code.",
"fetchErr": "An error occurred while fetching the HTTP code.", "fetchErr": "An error occurred while fetching the HTTP code.",

View File

@ -87,6 +87,7 @@
"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.", "dogImgErr": "Desculpe, mas não consegui obter a foto do cacbhorro que você queria.",
"foxApiErr": "Ocorreu um erro ao buscar dados da API.\n\n`{error}`", "foxApiErr": "Ocorreu um erro ao buscar dados da API.\n\n`{error}`",
"duckApiErr": "Ocorreu um erro ao buscar dados da API.\n\n`{error}`",
"httpCodes": { "httpCodes": {
"invalidCode": "Por favor, insira um código HTTP válido.", "invalidCode": "Por favor, insira um código HTTP válido.",
"fetchErr": "Ocorreu um erro ao buscar o código HTTP.", "fetchErr": "Ocorreu um erro ao buscar o código HTTP.",

View File

@ -19,5 +19,6 @@
"quoteApi": "https://quotes-api-self.vercel.app/quote", "quoteApi": "https://quotes-api-self.vercel.app/quote",
"weatherApi": "https://api.weather.com/v3", "weatherApi": "https://api.weather.com/v3",
"randomPonyApi": "https://theponyapi.com/api/v1/pony/random", "randomPonyApi": "https://theponyapi.com/api/v1/pony/random",
"foxApi": "https://randomfox.ca/floof/" "foxApi": "https://randomfox.ca/floof/",
"duckApi": "https://random-d.uk/api/v2/random"
} }