Add random dog image
This commit is contained in:
parent
aed36a1e9b
commit
0264c120d7
4 changed files with 32 additions and 3 deletions
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
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue