Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function IsHero(tbl)
- if type(tbl._attr)=="table"
- and type(tbl._attr.class)=="string"
- and (tbl._attr.class=="rgAltRow" or tbl._attr.class=="rgRow")
- and tbl[4]
- and tbl[4][1]
- and tbl[4][1]._attr
- and tbl[4][1]._attr.href
- and tbl[4][1]._attr.href:find("/Sitewide/HeroDetails?Hero=",1,true)
- then
- return true;
- else
- return false;
- end
- end
- local function InsertHeroStats(tbl, raw)
- local entry = {};
- entry.name = raw[4][1][1];
- entry.win = raw[8][1];
- entry.games = raw[6][1];
- if type(raw[5][1])=="table" then
- entry.level = raw[5][2][1];
- else
- entry.level = raw[5][1];
- end
- table.insert(tbl,entry);
- end
- local function FindHeroStats(tbl, existing)
- if not tbl then return nil; end
- local stats = existing or {};
- for k,v in pairs(tbl)do
- if type(v)=="table" then
- if(IsHero(v))then
- InsertHeroStats(stats,v);
- else
- FindHeroStats(v,stats);
- end
- end
- end
- return stats;
- end
- --[[return function(msg,usr,chan)
- if msg==nil or msg=="" or msg==" " then
- return;
- end
- local body, code, headers, status = MOD.HTTPGet("http://www.hotslogs.com/Player/Profile?PlayerID="..tostring(MOD.HotsLogsID));
- local hero = msg;
- if body then
- local parsed = HTML(body);
- local stats = FindHeroStats(parsed);
- if not stats then
- print("Unable to decode data");
- return;
- end
- for n=1, #stats do
- if(stats[n].name:lower()==hero:lower())then
- print(stats[n].name.." ");
- print("Games: "..tostring(stats[n].games));
- print("Level: "..tostring(stats[n].level));
- print("Win Percent: "..tostring(stats[n].win));
- return;
- end
- end
- print("Unable to find data for "..hero);
- else
- print("Unable to fetch data");
- end
- end]]
- return nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement