mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-04-28 17:15:57 +00:00
25 lines
919 B
JavaScript
25 lines
919 B
JavaScript
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;
|
|
}
|
|
});
|
|
} |