Chan Stats
Posted by Swoop
Friday, July 02, 2004
Description: ya
here it is, im not completley done, but if you have any suggestions, feel free to coment
here it is, im not completley done, but if you have any suggestions, feel free to coment
on *:LOAD:{
set %statschan $?"Enter the channel you wanna keep stats on"
}
on *:connect:{
hmake stats 1000
hload stats stats.hsh
timerupdate 0 3600 /update
}
;;Sort
alias rank {
var %num = 1
var %y = 1
write -c list.txt
write -c oneline.txt
while (%num <= $hfind(stats,*lines,0,w)) {
write list.txt $hget(stats,$hfind(stats,*lines,%num,w))
inc %num
}
while (%y <= $hfind(stats,*oneliners*,0,w)) {
write oneline.txt $hget(stats,$hfind(stats,*oneliners*,%y,w))
inc %y
}
}
alias plzsort {
var %x = 1
while (%x <= $lines(list.txt)) {
if (!$read(plzsort.txt,w,$read(list.txt,%x))) {
if (!$exists(plzsort.txt)) write plzsort.txt $read(list.txt,%x)
elseif ($gettok($read(list.txt,%x),2,58) >= $gettok($read(plzsort.txt,1),2,58)) write -il1 plzsort.txt $read(list.txt,%x)
elseif ($gettok($read(list.txt,%x),2,58) < $gettok($read(plzsort.txt,1),2,58)) {
var %i = 1
while (%i <= $lines(plzsort.txt)) {
if (!$read(plzsort.txt,w,$read(list.txt,%x))) {
if ($gettok($read(list.txt,%x),2,58) >= $gettok($read(plzsort.txt,%i),2,58)) {
write $+(-il,%i) plzsort.txt $read(list.txt,%x)
var %i = $lines(plzsort.txt)
}
elseif (%i == $lines(plzsort.txt)) write plzsort.txt $read(list.txt,%x)
}
inc %i
}
}
}
inc %x
}
return $read(plzsort.txt,1) $read(plzsort.txt,2) $read(plzsort.txt,3) $read(plzsort.txt,4) $read(plzsort.txt,5) $read(plzsort.txt,6) $read(plzsort.txt,7) $read(plzsort.txt,8) $read(plzsort.txt,9) $read(plzsort.txt,10)
}
alias onelinesort {
var %x = 1
while (%x <= $lines(oneline.txt)) {
if (!$read(onelinesort.txt,w,$read(oneline.txt,%x))) {
if (!$exists(onelinesort.txt)) write onelinesort.txt $read(oneline.txt,%x)
elseif ($gettok($read(oneline.txt,%x),2,58) >= $gettok($read(onelinesort.txt,1),2,58)) write -il1 onelinesort.txt $read(oneline.txt,%x)
elseif ($gettok($read(oneline.txt,%x),2,58) < $gettok($read(onelinesort.txt,1),2,58)) {
var %i = 1
while (%i <= $lines(onelinesort.txt)) {
if (!$read(onelinesort.txt,w,$read(oneline.txt,%x))) {
if ($gettok($read(oneline.txt,%x),2,58) >= $gettok($read(onelinesort.txt,%i),2,58)) {
write $+(-il,%i) onelinesort.txt $read(oneline.txt,%x)
var %i = $lines(onelinesort.txt)
}
elseif (%i == $lines(onelinesort.txt)) write plzsort.txt $read(oneline.txt,%x)
}
inc %i
}
}
}
inc %x
}
}
alias update {
/rank
remove plzsort.txt
remove onelinesort.txt
timer 1 5 /plzsort
timer 1 5 /onelinesort
hsave -o stats stats.hsh
set %updatetime $fulldate
}
on *:text:*:%statschan:{
if (!$hget(stats)) {
hmake stats 1000
hload stats stats.hsh
}
if ($1 == @stats) {
if (!$2) {
msg $chan [^B]Total Ranked[^B]: $hfind(stats,*lines,0,w) [^B]Commands[^B]: @shortlines <Nick/top10> @rank <rank number> @stats <Nick/Top10>
}
elseif ($2 == Top10) {
var %read1 = $read(plzsort.txt,1)
var %read2 = $read(plzsort.txt,2)
var %read3 = $read(plzsort.txt,3)
var %read4 = $read(plzsort.txt,4)
var %read5 = $read(plzsort.txt,5)
var %read6 = $read(plzsort.txt,6)
var %read7 = $read(plzsort.txt,7)
var %read8 = $read(plzsort.txt,8)
var %read9 = $read(plzsort.txt,9)
var %read10 = $read(plzsort.txt,10)
msg $chan [^B]Top 10[^B]: $+($replacex(%read1 %read2 %read3 %read4 %read5 %read6 %read7 %read8 %read9 %read10,$chr(58),$+($chr(32),$chr(40)),$chr(32),$+($chr(41),$chr(44),$chr(32))),$chr(41))
}
elseif ($read(plzsort.txt,w,* $+ $2 $+ *)) {
msg $chan [^B]Name[^B]: $gettok($read(plzsort.txt,w,* $+ $2 $+ *),1,58) [^B]Rank[^B]: $readn [^B]Lines[^B]: $gettok($read(plzsort.txt,w,* $+ $2 $+ *),2,58) [^B]Last Line[^B]: $hget(stats,$nick $+ .lastline)
msg $chan [^B]Updated[^B]: %updatetime
}
else {
msg $chan Sorry, $2 Was Not Found on the Stats Page
}
}
if ($1 == @rank) {
if (!$2) {
msg $chan You need to specify a rank
}
elseif ($2 > $lines(plzsort.txt)) {
msg $chan Nobody is ranked that low
}
else {
msg $chan [^B]Rank[^B]: $2 [^B]Name[^B]: $gettok($read(plzsort.txt,$2),1,58) [^B]Lines[^B]: $gettok($read(plzsort.txt,$2),2,58) [^B]Last Line[^B]: $hget(stats,$gettok($read(plzsort.txt,$2),1,58) $+ .lastline)
msg $chan [^B]Updated[^B]: %updatetime
}
}
if ($1 == @shortlines) {
if ($2 == Top10) {
var %read11 = $read(onelinesort.txt,1)
var %read12 = $read(onelinesort.txt,2)
var %read13 = $read(onelinesort.txt,3)
var %read14 = $read(onelinesort.txt,4)
var %read15 = $read(onelinesort.txt,5)
var %read16 = $read(onelinesort.txt,6)
var %read17 = $read(onelinesort.txt,7)
var %read18 = $read(onelinesort.txt,8)
var %read19 = $read(onelinesort.txt,9)
var %read20 = $read(ponelinesort.txt,10)
msg $chan [^B]Top 10[^B]: $+($replacex(%read11 %read12 %read13 %read14 %read15 %read16 %read17 %read18 %read19 %read20,$chr(58),$+($chr(32),$chr(40)),$chr(32),$+($chr(41),$chr(44),$chr(32))),$chr(41))
}
else {
msg $chan [^B]Name[^B]: $gettok($read(onelinesort.txt,w,* $+ $2 $+ *),1,58) [^B]Rank[^B]: $readn [^B]Number Of Short Lines(under 4 chr's)[^B]: $gettok($read(onelinesort.txt,w,* $+ $2 $+ *),2,58)
}
}
if (($1 == @update) && ($level($address($nick,2)) > 9)) {
/rank
remove plzsort.txt
remove onelinesort.txt
timer 1 5 /plzsort
timer 1 5 /onelinesort
timer 1 5 /msg $chan Update Complete
hsave -o stats stats.hsh
set %updatetime $fulldate
}
if (($1 == @restartstats) && ($level($address($nick,2)) > 9)) {
remove stats.hsh
hfree stats
}
if ($1 == @totalranked) {
msg $chan [^B]Total Names Ranked[^B] == $hfind(stats,*lines,0,w)
}
hadd stats $nick $+ .lastline $1- ( $+ $asctime(ddd mmm HH:nn:ss) $+ )
if (!$hfind(stats,$address($nick,2) $+ .lines,1)) {
hadd stats $+($address($nick,2),.lines) $nick $+ :1
}
else {
var %tempnum $calc($gettok($hget(stats, $+($address($nick,2),.lines)),2,58) + 1)
hadd stats $address($nick,2) $+ .lines $nick $+ : $+ %tempnum
}
if (!$hget(stats,$address($nick,2) $+ .nick)) {
hadd stats $address($nick,2) $+ .nick $nick
}
elseif ($nick !isin $hget(stats,$address($nick,2) $+ .nick)) {
hadd stats $address($nick,2) $+ .nick $hget(stats,$address($nick,2)) $+ .nick $nick
}
if ($len($1-) <= 4) {
if (!$hget(stats,$+(oneliners.,$address($nick,2)))) {
hadd stats $+(oneliners.,$address($nick,2)) $nick $+ :1
}
else {
hadd stats oneliners. $+ $address($nick,2) $nick $+ : $+ $calc($gettok($hget(stats, $+(oneliners.,$address($nick,2))),2,58) + 1)
}
}
}