mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
Add /rpony + polishment on other commands
This commit is contained in:
parent
2d02e6213f
commit
d4dfe160e1
@ -86,8 +86,8 @@ module.exports = (bot) => {
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
ctx.reply(Strings.ponyApi.apiErr, {
|
||||
const message = Strings.ponyApi.apiErr.replace('{error}', error.message);
|
||||
ctx.reply(message, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
@ -155,8 +155,8 @@ module.exports = (bot) => {
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
ctx.reply(Strings.ponyApi.apiErr, {
|
||||
const message = Strings.ponyApi.apiErr.replace('{error}', error.message);
|
||||
ctx.reply(message, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
@ -222,8 +222,8 @@ module.exports = (bot) => {
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
ctx.reply(Strings.ponyApi.apiErr, {
|
||||
const message = Strings.ponyApi.apiErr.replace('{error}', error.message);
|
||||
ctx.reply(message, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
|
36
src/commands/randompony.js
Normal file
36
src/commands/randompony.js
Normal file
@ -0,0 +1,36 @@
|
||||
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(["rpony", "randompony"], spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
try {
|
||||
const response = await axios(Resources.randomPonyApi);
|
||||
let tags = [];
|
||||
|
||||
if (response.data.pony.tags) {
|
||||
if (typeof response.data.pony.tags === 'string') {
|
||||
tags.push(response.data.pony.tags);
|
||||
} else if (Array.isArray(response.data.pony.tags)) {
|
||||
tags = tags.concat(response.data.pony.tags);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.replyWithPhoto(response.data.pony.representations.full, {
|
||||
caption: `${response.data.pony.sourceURL}\n\n${tags.length > 0 ? tags.join(', ') : 'N/A'}`,
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
} catch (error) {
|
||||
const message = Strings.ponyApi.apiErr.replace('{error}', error.message);
|
||||
ctx.reply(message, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
@ -94,7 +94,7 @@
|
||||
},
|
||||
"ponyApi": {
|
||||
"helpEntry": "My Little Pony",
|
||||
"helpDesc": "*My Little Pony*\n\n- /mlp: Displays this help message.\n- /mlpchar `<character name>`: Shows specific information about a My Little Pony character. Example: `/mlpchar twilight`\n- /mlpep: Shows specific information about a My Little Pony episode. Example: `/mlpep 136`",
|
||||
"helpDesc": "*My Little Pony*\n\n- /mlp: Displays this help message.\n- /mlpchar `<character name>`: Shows specific information about a My Little Pony character. Example: `/mlpchar Twilight Sparkle`\n- /mlpep: Shows specific information about a My Little Pony episode. Example: `/mlpep 136`\n- /mlpcomic `<comic name>`: Shows specific information about a My Little Pony comic. Example: `/mlpcomic Nightmare Rarity`\n- /rpony | /randompony: Sends a random artwork made by the My Little Pony community.",
|
||||
"charRes": "*MLP Character Information for* \"`{input}`\"*:*\n\n*Name:* `{name}`\n*Alias*: `{alias}`\n*Fandom URL:* [{url}]({url})\n*Sex:* `{sex}`\n*Residence:* `{residence}`\n*Occupation:* `{occupation}`\n*Kind:* `{kind}`",
|
||||
"epRes": "*MLP Episode Information for* \"`{input}`\"*:*\n\n*Name:* `{name}`\n*Fandom URL:* [{url}]({url})\n*Season:* `{season}`\n*Episode:* `{episode}`\n*Overall Ep.:* `{overall}`\n*Release date:* `{airdate}`\n*Story by:* `{storyby}`\n*Written by:* `{writtenby}`\n*Storyboard:* `{storyboard}`",
|
||||
"comicRes": "*MLP Comic Information for* \"`{input}`\"*:*\n\n*Name:* `{name}`\n*Fandom URL:* [{url}]({url})\n*Series:* `{series}`\n*Writer:* `{writer}`\n*Artist:* `{artist}`\n*Colorist:* `{colorist}`\n*Letterer:* `{letterer}`\n*Editor:* `{editor}`",
|
||||
@ -104,7 +104,7 @@
|
||||
"noEpisodeFound": "No episode found.",
|
||||
"noComicName": "Please provide the comic's name.",
|
||||
"noComicFound": "No comic found.",
|
||||
"apiErr": "An error occurred while fetching data from the API."
|
||||
"apiErr": "An error occurred while fetching data from the API.\n\n`{error}`"
|
||||
},
|
||||
"codenameCheck": {
|
||||
"noCodename": "Please provide a codename to search.",
|
||||
|
@ -94,7 +94,7 @@
|
||||
},
|
||||
"ponyApi": {
|
||||
"helpEntry": "My Little Pony",
|
||||
"helpDesc": "*My Little Pony*\n\n- /mlp: Exibe esta mensagem de ajuda.\n- /mlpchar `<nome do personagem>`: Mostra informações específicas sobre um personagem de My Little Pony em inglês. Exemplo: `/mlpchar twilight`\n- /mlpep: Mostra informações específicas sobre um episódio de My Little Pony em inglês. Exemplo: `/mlpep 136`",
|
||||
"helpDesc": "*My Little Pony*\n\n- /mlp: Exibe esta mensagem de ajuda.\n- /mlpchar `<nome do personagem>`: Mostra informações específicas sobre um personagem de My Little Pony em inglês. Exemplo: `/mlpchar twilight`\n- /mlpep: Mostra informações específicas sobre um episódio de My Little Pony em inglês. Exemplo: `/mlpep 136`\n- /mlpcomic `<nome da comic>`: Mostra informações específicas sobre uma comic de My Little Pony em inglês. Exemplo: `/mlpcomic Nightmare Rarity`\n- /rpony | /randompony: Envia uma arte aleatória feita pela comunidade de My Little Pony.",
|
||||
"charRes": "*Informações do Personagem de MLP para* `{input}`*:*\n\n*Nome:* `{name}`\n*Apelido:* `{alias}`\n*URL do Fandom:* [{url}]({url})\n*Sexo:* `{sex}`\n*Residência:* `{residence}`\n*Ocupação:* `{occupation}`\n*Tipo:* `{kind}`",
|
||||
"epRes": "*Informações do Episódio de MLP para* `{input}`*:*\n\n*Nome:* `{name}`\n*URL do Fandom:* [{url}]({url})\n*Temporada:* `{season}`\n*Episódio:* `{episode}`\n*Episódio Geral:* `{overall}`\n*Data de Lançamento:* `{airdate}`\n*História por:* `{storyby}`\n*Escrito por:* `{writtenby}`\n*Storyboard:* `{storyboard}`",
|
||||
"comicRes": "*Informações da Comic de MLP para* \"`{input}`\"*:*\n\n*Nome:* `{name}`\n*URL do Fandom:* [{url}]({url})\n*Série:* `{series}`\n*Escritor:* `{writer}`\n*Artista:* `{artist}`\n*Colorista:* `{colorist}`\n*Letrista:* `{letterer}`\n*Editor:* `{editor}`",
|
||||
@ -104,7 +104,7 @@
|
||||
"noEpisodeFound": "Nenhum episódio encontrado.",
|
||||
"noComicName": "Por favor, forneça o nome da comic.",
|
||||
"noComicFound": "Nenhuma comic foi encontrada.",
|
||||
"apiErr": "Ocorreu um erro ao buscar dados da API."
|
||||
"apiErr": "Ocorreu um erro ao buscar dados da API.\n\n`{error}`"
|
||||
},
|
||||
"codenameCheck": {
|
||||
"noCodename": "Por favor, forneça um codinome para pesquisar.",
|
||||
|
@ -17,5 +17,6 @@
|
||||
"modArchiveApi": "https://api.modarchive.org/downloads.php?moduleid=",
|
||||
"ponyApi": "http://ponyapi.net/v1",
|
||||
"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"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user