mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Uncommented /mlpcomic + some changes on help
This commit is contained in:
parent
b60e8017c1
commit
d33ed0afcb
@ -7,7 +7,7 @@ async function sendHelpMessage(ctx, isEditing) {
|
|||||||
const botInfo = await ctx.telegram.getMe();
|
const botInfo = await ctx.telegram.getMe();
|
||||||
const helpText = Strings.botHelp
|
const helpText = Strings.botHelp
|
||||||
.replace('{botName}', botInfo.first_name)
|
.replace('{botName}', botInfo.first_name)
|
||||||
.replace("{sourceLink}", `${process.env.botSource}`);
|
.replace("{sourceLink}", process.env.botSource);
|
||||||
const options = {
|
const options = {
|
||||||
parse_mode: 'Markdown',
|
parse_mode: 'Markdown',
|
||||||
disable_web_page_preview: true,
|
disable_web_page_preview: true,
|
||||||
|
@ -162,71 +162,70 @@ module.exports = (bot) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bot.command("mlpcomic", spamwatchMiddleware, async (ctx) => {
|
||||||
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
|
const userInput = ctx.message.text.split(' ').slice(1).join(' ');
|
||||||
|
|
||||||
// bot.command("mlpcomic", spamwatchMiddleware, async (ctx) => {
|
if (!userInput) {
|
||||||
// const Strings = getStrings(ctx.from.language_code);
|
ctx.reply(Strings.ponyApi.noComicName, {
|
||||||
// const userInput = ctx.message.text.split(' ').slice(1).join(' ');
|
parse_mode: 'Markdown',
|
||||||
|
reply_to_message_id: ctx.message.message_id
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
// if (!userInput) {
|
const apiUrl = `http://ponyapi.net/v1/comics-story/${userInput}`;
|
||||||
// ctx.reply(Strings.ponyApi.noComicName, {
|
|
||||||
// parse_mode: 'Markdown',
|
|
||||||
// reply_to_message_id: ctx.message.message_id
|
|
||||||
// });
|
|
||||||
// return;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const apiUrl = `http://ponyapi.net/v1/comics-story/${userInput}`;
|
try {
|
||||||
|
const response = await axios(apiUrl);
|
||||||
|
const comicArray = [];
|
||||||
|
console.log(response.data.data)
|
||||||
|
if (Array.isArray(response.data.data)) {
|
||||||
|
response.data.data.forEach(comic => {
|
||||||
|
comicArray.push({
|
||||||
|
name: comic.name,
|
||||||
|
series: comic.series,
|
||||||
|
image: comic.image,
|
||||||
|
url: comic.url,
|
||||||
|
writer: comic.writer ? comic.writer.replace(/\n/g, ' / ') : 'N/A',
|
||||||
|
artist: comic.artist ? comic.artist.replace(/\n/g, ' / ') : 'N/A',
|
||||||
|
colorist: comic.colorist ? comic.colorist.replace(/\n/g, ' / ') : 'N/A',
|
||||||
|
letterer: comic.letterer ? comic.letterer.replace(/\n/g, ' / ') : 'N/A',
|
||||||
|
editor: comic.editor
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// try {
|
if (comicArray.length > 0) {
|
||||||
// const response = await axios(apiUrl);
|
const result = Strings.ponyApi.comicRes
|
||||||
// const comicArray = [];
|
.replace("{input}", userInput)
|
||||||
// console.log(response.data.data)
|
.replace("{name}", comicArray[0].name)
|
||||||
// if (Array.isArray(response.data.data)) {
|
.replace("{series}", comicArray[0].series)
|
||||||
// response.data.data.forEach(comic => {
|
.replace("{url}", comicArray[0].url)
|
||||||
// comicArray.push({
|
.replace("{writer}", comicArray[0].writer)
|
||||||
// name: comic.name,
|
.replace("{artist}", comicArray[0].artist)
|
||||||
// series: comic.series,
|
.replace("{colorist}", comicArray[0].colorist)
|
||||||
// image: comic.image,
|
.replace("{letterer}", comicArray[0].writtenby)
|
||||||
// url: comic.url,
|
.replace("{editor}", comicArray[0].editor);
|
||||||
// writer: comic.writer ? comic.writer.replace(/\n/g, ' / ') : 'N/A',
|
|
||||||
// artist: comic.artist ? comic.artist.replace(/\n/g, ' / ') : 'N/A',
|
|
||||||
// colorist: comic.colorist ? comic.colorist.replace(/\n/g, ' / ') : 'N/A',
|
|
||||||
// letterer: comic.letterer ? comic.letterer.replace(/\n/g, ' / ') : 'N/A',
|
|
||||||
// editor: comic.editor
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if (comicArray.length > 0) {
|
ctx.replyWithPhoto(comicArray[0].image, {
|
||||||
// const result = Strings.ponyApi.comicRes
|
caption: `${result}`,
|
||||||
// .replace("{input}", userInput)
|
parse_mode: 'Markdown',
|
||||||
// .replace("{name}", comicArray[0].name)
|
disable_web_page_preview: true,
|
||||||
// .replace("{series}", comicArray[0].series)
|
reply_to_message_id: ctx.message.message_id
|
||||||
// .replace("{url}", comicArray[0].url)
|
});
|
||||||
// .replace("{writer}", comicArray[0].writer)
|
} else {
|
||||||
// .replace("{artist}", comicArray[0].artist)
|
ctx.reply(Strings.ponyApi.noComicFound, {
|
||||||
// .replace("{colorist}", comicArray[0].colorist)
|
parse_mode: 'Markdown',
|
||||||
// .replace("{letterer}", comicArray[0].writtenby)
|
reply_to_message_id: ctx.message.message_id
|
||||||
// .replace("{editor}", comicArray[0].editor);
|
});
|
||||||
|
};
|
||||||
// ctx.replyWithPhoto(comicArray[0].image, {
|
} catch (error) {
|
||||||
// caption: `${result}`,
|
console.error(error);
|
||||||
// parse_mode: 'Markdown',
|
ctx.reply(Strings.ponyApi.apiErr, {
|
||||||
// disable_web_page_preview: true,
|
parse_mode: 'Markdown',
|
||||||
// reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
// });
|
});
|
||||||
// } else {
|
};
|
||||||
// ctx.reply(Strings.ponyApi.noComicFound, {
|
});
|
||||||
// parse_mode: 'Markdown',
|
|
||||||
// reply_to_message_id: ctx.message.message_id
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error(error);
|
|
||||||
// ctx.reply(Strings.ponyApi.apiErr, {
|
|
||||||
// parse_mode: 'Markdown',
|
|
||||||
// reply_to_message_id: ctx.message.message_id
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user