on *:start:hmake top10 1000 | hload top10 top10.hsh
on *:exit:hsave -a top10 top10.hsh
on me:*:join:#:hadd top10 $+(joined/,#) $ctime
on *:text:*:#:{
hinc -m top10 $+($nick,/,#) $regex($1-,/\S=/g)
if (%top10v) unset %top10v
if ($1 = !lines) { top10 # $nick | set -z %top10p 5 }
if ($nick isop #) {
if ($regex(top10,$1,/^\!top(\d\d?)$/)) {
if (%top10p) { .notice TopUsers: flood protection triggered. please wait 20 | return }
if ($regml(top10,1) isnum 5-10) {
.notice $nick TopUsers: The list is according to the time i've joined the channel on which: $asctime($hget(top10,$+(joined/,#)))
top10 # $regml(top10,1) $nick
.notice $nick TopUsers: Average lines difference is %top10v
set -z %top10p 20
}
elseif ($regml(top10,1) isnum 5-10) .notice $nick TopUsers: please specify a number within this range 5-10
}
}
}
alias top10 {
if (!$window(@top10)) window -h @top10
var %a = 1,%r
while %a <= $hget(top10,0).item {
if ($1 isin $hget(top10,%a).item) && (joined/ !isin $hget(top10,%a).item) {
aline @top10 $+($hget(top10,%a).item,=,$hget(top10,%a).data)
}
inc %a
}
filter -cwwtue 2 $asc(=) @top10 @top10 *
if ($left($2,1) !isnum) goto next
%a = 1
while $line(@top10,%a) {
var %b = %b $+($chr(22),[,%a,],$chr(22)) $iif($token($token($ifmatch,1,$asc(=)),1,$asc(/)) ison $1,$+($chr(2),$v1,$chr(2)),$v1) $+($chr(40),$token($line(@top10,%a),2,$asc(=)),$chr(41))
set %top10v $addtok(%top10v,$token($ifmatch,2,$asc(=)),$asc(-))
if (%a = $2) break
inc %a
}
msg $1 Top $+ $2 $+ (Lines): %b $+($chr(22),$chr(32),$chr(2),$chr(32),$chr(2),$chr(22))
set %top10v $abs($calc($calc(%top10v) / $numtok(%top10v,$asc(-))))
:next
if ($left($2,1) !isnum) .notice $2 TopUsers: You wrote on $remove($1,#) $hget(top10,$+($2,/,$1)) $iif($hget(top10,$+($2,/,$1)) > 1,lines,lines) $+ . (You are at the $ord($fline(@top10,$+(/,$2,\//i),1,2)) position in the rank.)
window -c @top10
}