.konfizius
This commit is contained in:
parent
9afd536a5e
commit
f2461b04e1
|
@ -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§ion=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(/(“|„)/g, ''));
|
||||
|
||||
return e.reply(`[b]Konfuzius sagt:[/b] ${quotes[~~(Math.random() * quotes.length)]}`);
|
||||
|
||||
}
|
||||
}];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user