import fetch from "flumm-fetch-cookies"; export default async bot => { return [{ name: "irpg", call: /^\.irpg/i, set: "uwe", f: async e => { const res = await (await fetch("https://f0ck.me/irpg/db.php")).text(); e.args[0] = e.args[0] || e.user.nick; let players = new Map() , alias = {}; res .split("\n").join`` .match(/\<tr\>(.*?)\<\/tr\>/gsi) .map((l, i) => `<td>${i}</td>${l}`.match(/\<td.*?\>(.*?)\<\/td\>/gsi)) .map(l => l?l.map(m => m .replace("<td>", "") .replace("<td nowrap>", "") .replace("</td>", "") ):false) .splice(1) .forEach(p => { // 6 archangel!archangel@pomf.space const nick = p[6].split("!")[0].toLowerCase(); players.set(p[1].toLowerCase(), { rang: parseInt(p[0]), name: p[1], level: parseInt(p[2]), class: p[4], ttl: p[5], online: p[7] === "Yes", nick: nick, itemsum: parseInt(p[31]) }); if(nick !== p[1].toLowerCase()) alias[nick] = p[1].toLowerCase(); }); e.args[0] = (e.args[0].toLowerCase() in alias)?alias[e.args[0].toLowerCase()]:e.args[0]; let p = players.has(e.args[0].toLowerCase())?players.get(e.args[0].toLowerCase()):false; let tmp = e.args[0].match(/#\d+/); if(tmp) { tmp = parseInt(tmp[0].slice(1)) - 1; if(tmp >= 0 && tmp <= players.size - 1) p = [...players.entries()][tmp][1]; } if(!p) return e.reply("user / rang doesn't exist. D:"); e.reply(`(${p.rang} / ${players.size}) [b]${p.name}[/b], the [b]${p.class}[/b] is ${p.online?"[color=green]online[/color]":"[color=red]offline[/color]"}: level: ${p.level}, next level in ${p.ttl}. Itemsum: ${p.itemsum}`); } }]; };