on *:sockread:RSStats*: {
sockread &Incoming
bwrite $sockname -1 -1 &Incoming
if ($sockerr) {
if ($sockname == RSStats) xdid -t RSStats 13 An error occured during stats lookup
else %display $c1(An error occured during stats lookup)
cleanup $sockname
}
elseif ($bfind(&Incoming, 1, </html>).text) process $sockname
elseif ($bfind(&Incoming, 1, does not feature in the hiscores.).text) {
if ($sockname == RSStats) xdid -t RSStats 13 The nick %RSStats.rsn does not appear in the hiscores
else %display $c1(The nick) $c2(%RSStats.rsn) $c1(does not appear in the hiscores)
cleanup $sockname
}
}
; ##############################################################################
; # Process alias #
; ##############################################################################
alias -l process {
var %file = $1
bread %file 1 $file(%file).size &stats
var %currentstat, %x = 1
while (%x) {
var %x = $bfind(&stats,$calc(%x + 1),<a href="overall.ws?table=)
var %currentstat = $striptags($bvar(&stats,%x,200).text)
tokenize 32 %currentstat
if ($1 == Overall) set %RSStats.overall.xp $4
if ($2) hadd -m %file $1 $2 $3 $4 $xp2next($3,$4).format $getPercent($4)
}
cleanup %file
}