This commit is contained in:
Flummi 2017-11-23 19:01:51 +01:00
parent 7fde3b08fc
commit c10a5884a2

View File

@ -1,6 +1,6 @@
import sql from "../sql.js"; import sql from "../sql.js";
const request = require("request") const rp = require("request-promise")
, xmlparse = require('xml2js').parseString; , jsdom = require("jsdom").JSDOM;
const data = { const data = {
abschieben: [], abschieben: [],
@ -358,14 +358,31 @@ module.exports = bot => {
args.shift(); args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
request(`http://idlerpg.rizon.net/xml.php?player=${args[0]}`, (err, res, body) => { rp("http://idlerpg.rizon.net/players.php").then(top => {
xmlparse(body, (err, body) => { let prank = 0
console.log(body); , i = 1;
if(body.player.username[0].length <= 1) const dom = new jsdom(top);
return e.reply(`player [b]${args[0]}[/b] was not found`); let playerlist = dom.window.document.querySelectorAll("ol > li");
e.reply(`[b]${body.player.username[0]}[/b], the [b]${body.player.class[0]}[/b]: level: ${body.player.level[0]}, online: ${(body.player.online[0]=="1").toString()}.`); let player = null;
}); for(let p of playerlist) {
if (p.innerHTML.includes(`player=${args[0]}`)) {
prank = i;
player = p;
break;
}
i++;
}
if(player !== null) {
let tmp = player.innerHTML.match(/.*, the level (.*?) (.*?)\. Next level in (.*?)\./);
let plevel = tmp[1]
, pclass = tmp[2]
, puntil = tmp[3]
e.reply(`([i]${prank} / ${playerlist.length}[/i]) [b]${args[0]}[/b], the [b]${pclass}[/b]: level: ${plevel}, next level in ${puntil}.`);
}
else
e.reply(`player [b]${args[0]}[/b] was not found`);
}); });
} }
}); });