On *:text:-stats *:#:{
if $network == Gamesurge { stat $2 # }
}
alias stat {
;
; Usage: /stat <character> [nick|#chan]
;
if !$1 || $sock(stat) { return }
set %RS.statname $1
;
; %RS.output holds the command through which the information will be returned
; if no [nick|#chan] value is specified, the info will be displayed locally (echo)
;
set %RS.output $iif($2,notice $nick,echo 5 -agt *)
set %RS.collect Overall Attack Defence Strength Hitpoints Ranged Prayer Magic Cooking Woodcutting Firemaking Mining Smithing Fishing Crafting Thieving Fletching Herblore Runecrafting Agility
%RS.output Collecting stats for %RS.statname $+ ...
sockopen stat hiscore.runescape.com 80
}
alias -l nohtml var %a | !.echo -q $regsub($1-,/^.*?>|<.*?>|<.*?$/g,,%a) | return %a
On *:sockopen:stat:{
if $sockerr {
%RS.output Error contacting website.
unset %RS.*
return
}
var %a = sockwrite -tn stat
%a GET /aff/runescape/hiscorepersonal.cgi?username= $+ %RS.statname HTTP/1.0
%a Host: hiscore.runescape.com
%a Connection: close
%a
}
On *:sockread:stat:{
var %a
;
; read a CRLF-terminated line into a local variable
;
sockread %a
while $sockbr {
;
; first we filter possible attribute lines
;
if <td>*</a></td> iswm %a {
var %attrib = $nohtml(%a)
;
; do we want this attribute?
;
if $istok(%RS.collect,%attrib,32) {
;
; if so, append it to the final information line...
;
set %RS.info %RS.info 12 $+ %attrib
set %RS.lookForValue 1
}
}
;
; commas are not recognized by the isnum operator
; therefore we remove them before validating a numeric value
;
elseif %RS.lookForValue && $remove(%a,$chr(44)) isnum {
set %RS.info %RS.info =04 %a
unset %RS.lookForValue
}
sockread %a
}
}
On *:sockclose:stat:{
if %RS.info {
%RS.output Stats for %RS.statname $+ :
%RS.output %RS.info
}
else {
notice $nick %RS.output [ZF-Bot] is collecting stats for %RS.statname
}
unset %RS.*
}