.konfizius
This commit is contained in:
parent
9afd536a5e
commit
f2461b04e1
|
@ -1,9 +1,10 @@
|
||||||
import fetch from "flumm-fetch-cookies";
|
import fetch from "flumm-fetch-cookies";
|
||||||
|
import { parse } from "node-html-parser";
|
||||||
|
|
||||||
const apis = {
|
const apis = {
|
||||||
launch: 'https://fdo.rocketlaunch.live/json/launches/next/1',
|
launch: 'https://fdo.rocketlaunch.live/json/launches/next/1',
|
||||||
fml: 'https://www.fmylife.com/random',
|
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 => {
|
f: async e => {
|
||||||
let res;
|
let res;
|
||||||
try {
|
try {
|
||||||
res = (await (await fetch(apis.konfuzius)).json()).parse.text['*'];
|
res = await (await fetch(apis.konfuzius)).text();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const quotes = res
|
const quotes = [...parse(res).querySelectorAll('ol strong')]
|
||||||
.replace(/<a.+?>(.+?)<\/a>/g, '$1')
|
.map(d => d.innerText.replace(/(“|„)/g, ''));
|
||||||
.match(/<ul><li>\"(.*?)\" - <i>.*?<\/ul>/gm)
|
|
||||||
.map(a => a.match(/\"(.*)\"/)[1]);
|
|
||||||
|
|
||||||
return e.reply(`[b]Konfuzius sagt:[/b] ${quotes[~~(Math.random() * quotes.length)]}`);
|
return e.reply(`[b]Konfuzius sagt:[/b] ${quotes[~~(Math.random() * quotes.length)]}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user