mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
Add random dog image
This commit is contained in:
parent
aed36a1e9b
commit
0264c120d7
26
commands/dog.js
Normal file
26
commands/dog.js
Normal 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
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
@ -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."
|
||||
}
|
@ -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."
|
||||
}
|
@ -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."
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user