mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Random quotes (WIP), not included in /help yet
This commit is contained in:
parent
8b1c912520
commit
f9d6117752
29
commands/quotes.js
Normal file
29
commands/quotes.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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("quote", spamwatchMiddleware, async (ctx) => {
|
||||||
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await axios.get('https://quotes-api-self.vercel.app/quote');
|
||||||
|
const data = response.data;
|
||||||
|
const escapedQuote = data.quote.replace(/([_*~`>.!-])/g, '\\$1');
|
||||||
|
const escapedAuthor = `- ${data.author}.`.replace(/([_*~`>.!-])/g, '\\$1');
|
||||||
|
const escapedData = `${Strings.quoteResult}\n>*${escapedQuote}*\n_${escapedAuthor}_`;
|
||||||
|
|
||||||
|
ctx.reply(escapedData, {
|
||||||
|
reply_to_message_id: ctx.message.message_id,
|
||||||
|
parse_mode: 'MarkdownV2'
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
ctx.reply(Strings.quoteErr, {
|
||||||
|
reply_to_message_id: ctx.message.id,
|
||||||
|
parse_mode: 'MarkdownV2'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
@ -72,5 +72,7 @@
|
|||||||
"botUpdated": "Bot updated with success.\n\n```{result}```",
|
"botUpdated": "Bot updated with success.\n\n```{result}```",
|
||||||
"errorUpdatingBot": "Error updating bot\n\n{error}",
|
"errorUpdatingBot": "Error updating bot\n\n{error}",
|
||||||
"catImgErr": "Sorry, but I couldn't get the cat GIF you wanted.",
|
"catImgErr": "Sorry, but I couldn't get the cat GIF you wanted.",
|
||||||
"catGifErr": "Sorry, but I couldn't get the cat photo you wanted."
|
"catGifErr": "Sorry, but I couldn't get the cat photo you wanted.",
|
||||||
|
"quoteResult": "Here is a random quote for you:",
|
||||||
|
"quoteErr": "Sorry, but something went wrong while displaying the quote."
|
||||||
}
|
}
|
@ -72,5 +72,7 @@
|
|||||||
"botUpdated": "Bot atualizado com sucesso.\n\n```{result}```",
|
"botUpdated": "Bot atualizado com sucesso.\n\n```{result}```",
|
||||||
"errorUpdatingBot": "Erro ao atualizar o bot\n\n{error}",
|
"errorUpdatingBot": "Erro ao atualizar o bot\n\n{error}",
|
||||||
"catImgErr": "Desculpe, mas não consegui obter o GIF do gato que você queria.",
|
"catImgErr": "Desculpe, mas não consegui obter o GIF do gato que você queria.",
|
||||||
"catGifErr": "Desculpe, mas não consegui obter a foto do gato que você queria."
|
"catGifErr": "Desculpe, mas não consegui obter a foto 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."
|
||||||
}
|
}
|
@ -72,5 +72,7 @@
|
|||||||
"botUpdated": "Bot actualizado con éxito.\n\n```{result}```",
|
"botUpdated": "Bot actualizado con éxito.\n\n```{result}```",
|
||||||
"errorUpdatingBot": "Error al actualizar el bot\n\n{error}",
|
"errorUpdatingBot": "Error al actualizar el bot\n\n{error}",
|
||||||
"catImgErr": "Lo siento, pero no pude obtener el GIF del gato que querías.",
|
"catImgErr": "Lo siento, pero no pude obtener el GIF del gato que querías.",
|
||||||
"catGifErr": "Lo siento, pero no pude obtener la foto del gato que querías."
|
"catGifErr": "Lo siento, pero no pude obtener la foto 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."
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user