Dont forget to set your channel in the top line!
alias clanavg.channel return #yourchannel
;
#clanavg on
on *:TEXT:!clanavg:$($clanavg.channel):{ clanavg | .disable #clanavg | .timer -o 1 30 .enable #clanavg }
#clanavg end
;
alias -l clanavg {
echo -at starting
sockclose clanavg
sockopen clanavg www.runehead.com 80
}
on *:sockopen:clanavg:{
sockwrite -n $sockname GET /clans/ml.php?clan=Theothers HTTP/1.0
sockwrite -n $sockname Host: www.runehead.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
on *:sockread:clanavg:{
var %text | sockread %text
if (!$sock(clanavg).mark) { if (<b>Avg Overall</b> isin %text) { sockmark clanavg 8 } }
elseif ($sock(clanavg).mark > 1) { sockmark clanavg $calc($sock(clanavg).mark - 1) }
else { msg $clanavg.channel Avg Overall is $gettok($gettok(%text,3,$asc(>)),1,$asc(<)) | sockclose clanavg }
}
* code was tested an ran fine *
The code is dependent on the website NOT changing much,
ie: it looks for the line with
<b>Avg Overall</b> on it, then just reads 8 lines down and assumes thats the value and gets it out of
<td style='width: 125px;'><b>1,604</b></td> being 1,604 in this case.
Also inacted a 30 second delay before the next !clanavg can be done, sicne it takes time for it to get the value.