.konfizius

This commit is contained in:
Flummi 2023-07-19 12:33:28 +02:00
parent 9afd536a5e
commit f2461b04e1

View File

@ -1,9 +1,10 @@
import fetch from "flumm-fetch-cookies";
import { parse } from "node-html-parser";
const apis = {
launch: 'https://fdo.rocketlaunch.live/json/launches/next/1',
fml: 'https://www.fmylife.com/random',
konfuzius: 'https://de.wikiquote.org/w/api.php?action=parse&format=json&pageid=155&section=2',
konfuzius: 'https://www.careelite.de/konfuzius-zitate-weisheiten-sprueche/',
};
@ -56,17 +57,16 @@ export default async bot => {
f: async e => {
let res;
try {
res = (await (await fetch(apis.konfuzius)).json()).parse.text['*'];
res = await (await fetch(apis.konfuzius)).text();
} catch(err) {
console.error(err);
}
const quotes = res
.replace(/<a.+?>(.+?)<\/a>/g, '$1')
.match(/<ul><li>\"(.*?)\" - <i>.*?<\/ul>/gm)
.map(a => a.match(/\"(.*)\"/)[1]);
const quotes = [...parse(res).querySelectorAll('ol strong')]
.map(d => d.innerText.replace(/(&#8220;|&#8222;)/g, ''));
return e.reply(`[b]Konfuzius sagt:[/b] ${quotes[~~(Math.random() * quotes.length)]}`);
}
}];
};