irpg
This commit is contained in:
parent
7fde3b08fc
commit
c10a5884a2
|
@ -1,6 +1,6 @@
|
|||
import sql from "../sql.js";
|
||||
const request = require("request")
|
||||
, xmlparse = require('xml2js').parseString;
|
||||
const rp = require("request-promise")
|
||||
, jsdom = require("jsdom").JSDOM;
|
||||
|
||||
const data = {
|
||||
abschieben: [],
|
||||
|
@ -357,15 +357,32 @@ module.exports = bot => {
|
|||
let args = e.message.trim().split(" ");
|
||||
args.shift();
|
||||
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) => {
|
||||
xmlparse(body, (err, body) => {
|
||||
console.log(body);
|
||||
if(body.player.username[0].length <= 1)
|
||||
return e.reply(`player [b]${args[0]}[/b] was not found`);
|
||||
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()}.`);
|
||||
});
|
||||
|
||||
rp("http://idlerpg.rizon.net/players.php").then(top => {
|
||||
let prank = 0
|
||||
, i = 1;
|
||||
const dom = new jsdom(top);
|
||||
let playerlist = dom.window.document.querySelectorAll("ol > li");
|
||||
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`);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user