mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
Removed comments on wiki.js + removed logging support (again)
This commit is contained in:
parent
15fd56e18f
commit
321bf39650
2
bot.js
2
bot.js
@ -4,7 +4,7 @@ const fs = require('fs');
|
||||
const Config = require('./props/config.json');
|
||||
const { isOnSpamWatch } = require('./plugins/lib-spamwatch/spamwatch.js');
|
||||
require('./plugins/ytdlp-wrapper.js');
|
||||
require('./plugins/termlogger.js');
|
||||
// require('./plugins/termlogger.js');
|
||||
|
||||
const bot = new Telegraf(Config.botToken);
|
||||
const MAX_RETRIES = 5;
|
||||
|
@ -14,7 +14,7 @@ function mediaWikiToMarkdown(input) {
|
||||
input = input.replace(/^\#\s/gm, '1. ');
|
||||
input = input.replace(/{{Quote(.*?)}}/g, "```\n$1```\n");
|
||||
input = input.replace(/\[\[(.*?)\|?(.*?)\]\]/g, (_, link, text) => {
|
||||
const sanitizedLink = link.replace(/ /g, '_'); // Substituir espaços por underscores
|
||||
const sanitizedLink = link.replace(/ /g, '_');
|
||||
return text ? `[${text}](${sanitizedLink})` : `[${sanitizedLink}](${sanitizedLink})`;
|
||||
});
|
||||
input = input.replace(/\[\[File:(.*?)\|.*?\]\]/g, '');
|
||||
@ -27,12 +27,10 @@ module.exports = (bot) => {
|
||||
const userInput = capitalizeFirstLetter(ctx.message.text.split(' ')[1]);
|
||||
const apiUrl = `https://en.wikipedia.org/w/index.php?title=${userInput}&action=raw`;
|
||||
const response = await axios(apiUrl, { headers: { 'Accept': "text/plain" } });
|
||||
|
||||
// Limpa a resposta e remove a infobox
|
||||
const convertedResponse = response.data.replace(/<\/?div>/g, "").replace(/{{Infobox.*?}}/s, "");
|
||||
|
||||
|
||||
const result = mediaWikiToMarkdown(convertedResponse).slice(0, 2048);
|
||||
|
||||
|
||||
ctx.reply(result, { parse_mode: 'Markdown', disable_web_page_preview: true, reply_to_message_id: ctx.message.message_id });
|
||||
});
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user