Top10 Ranking — File Browser

Top10Rankingv3.21 / Top10Rankingv3.21 / Top10 / TR321.mrc

TR321.mrc — 24.84 KB — Download this file

;Top10 Ranking v3.21 by equak
dialog topconfig {
  title "Top10 Ranking Configuration"
  size -1 -1 220 126
  option dbu
  box "Channels", 1, 4 2 153 36
  edit "", 2, 8 22 143 11
  text "Put # for all channels or put channels separated by commas:", 3, 8 12 147 8
  box "Options", 4, 4 39 153 68
  text "Words, letters, smilies, timewasted, places, stat and more:", 5, 8 49 144 8
  check "Enable actions", 6, 25 61 45 10
  check "Enable modes", 7, 25 72 45 10
  check "Enable joins", 8, 25 83 43 10
  check "Enable parts", 9, 25 94 42 10
  check "Enable kicks", 10, 92 61 43 10
  check "Enable notices", 11, 92 72 46 10
  check "Enable topics", 12, 92 83 48 10
  check "Enable ctcps", 13, 92 94 45 10
  box "Tips", 14, 160 2 57 105
  text "Be sure to exit mirc completely, not by alt-f4 or ctrl-alt-del, else the stats won't be saved", 15, 171 12 41 41, center
  text "1)", 16, 164 12 8 8
  text "2)", 17, 164 60 6 8
  text "I recommend that you run this script from a bot or you could freeze sometimes", 18, 171 60 41 41, center
  link "Download/Comments", 19, 64 113 53 8
  button "Update", 20, 134 111 37 12,ok
  button "Cancel", 21, 179 111 37 12,cancel
  check "Enable script", 22, 5 111 50 10
}
on *:dialog:topconfig:*:*: {
  if ($devent = init && $did = 0) {
    if (!%topchannels) { did -a $dname 2 $chr(35) | set %topchannels $did(2).text }
    elseif (%topchannels) { did -a $dname 2 %topchannels }
    if ($group(#toplist).status = on) { did -c $dname 22 }
    elseif ($group(#toplist).status = off) { did -u $dname 22 }
    if ($group(#topactions).status = on) { did -c $dname 6 }
    elseif ($group(#topactions).status = off) { did -u $dname 6 }
    if ($group(#topmodes).status = on) { did -c $dname 7 }
    elseif ($group(#topmodes).status = off) { did -u $dname 7 }
    if ($group(#topjoins).status = on) { did -c $dname 8 }
    elseif ($group(#topjoins).status = off) { did -u $dname 8 }
    if ($group(#topparts).status = on) { did -c $dname 9 }
    elseif ($group(#topparts).status = off) { did -u $dname 9 }
    if ($group(#topkicks).status = on) { did -c $dname 10 }
    elseif ($group(#topkicks).status = off) { did -u $dname 10 }
    if ($group(#topnotices).status = on) { did -c $dname 11 }
    elseif ($group(#topnotices).status = off) { did -u $dname 11 }
    if ($group(#toptopics).status = on) { did -c $dname 12 }
    elseif ($group(#toptopics).status = off) { did -u $dname 12 }
    if ($group(#topctcps).status = on) { did -c $dname 13 }
    elseif ($group(#topctcps).status = off) { did -u $dname 13 }
  }
  if ($devent = sclick && $did = 20) {
    if ($did($dname,22).state = 1) {
      .enable #toplist
      .timerchecktodaylist 0 1 checktodaylist
    }
    elseif ($did($dname,22).state = 0) {
      .disable #toplist
      .timerchecktodaylist off
      .timer*.#*.* off
    }
    set %topchannels $iif($did($dname,2).text,$ifmatch,$chr(35))
    if ($did($dname,6).state = 1) { .enable #topactions }
    elseif ($did($dname,6).state = 0) { .disable #topactions }
    if ($did($dname,7).state = 1) { .enable #topmodes }
    elseif ($did($dname,7).state = 0) { .disable #topmodes }
    if ($did($dname,8).state = 1) { .enable #topjoins }
    elseif ($did($dname,8).state = 0) { .disable #topjoins }
    if ($did($dname,9).state = 1) { .enable #topparts }
    elseif ($did($dname,9).state = 0) { .disable #topparts }
    if ($did($dname,10).state = 1) { .enable #topkicks }
    elseif ($did($dname,10).state = 0) { .disable #topkicks }
    if ($did($dname,11).state = 1) { .enable #topnotices }
    elseif ($did($dname,11).state = 0) { .disable #topnotices }
    if ($did($dname,12).state = 1) { .enable #toptopics }
    elseif ($did($dname,12).state = 0) { .disable #toptopics }
    if ($did($dname,13).state = 1) { .enable #topctcps }
    elseif ($did($dname,13).state = 0) { .disable #topctcps }  
  }
  if ($devent = sclick && $did = 19) { url http://www.mircscripts.org/comments.php?id=1444 }
}
menu channel,menubar {
  Top10 Ranking Configuration:dialog -m topconfig topconfig
}
on *:start: {
  var %x = 1
  while (%x <= $findfile($+(",$scriptdirtoplist\,"),*.hsh,0)) {
    hmake $deltok($nopath($findfile($+(",$scriptdirtoplist\,"),*.hsh,%x)),-1,46) 10000
    hload $deltok($nopath($findfile($+(",$scriptdirtoplist\,"),*.hsh,%x)),-1,46) " $+ $findfile($scriptdirtoplist\,*.hsh,%x) $+ "
    inc %x
  }
}
on *:exit: {
  var %x = 1
  while (%x <= $hget(0)) {
    if ($regex($hget(%x),^(words|letters|smilies|places|lines|actions|modes|joins|parts|notices|kicks|topics|timewasted|ctcps)(\_))) {
      hsave -o $hget(%x) $+(",$scriptdirtoplist\,$hget(%x),.hsh,")
    }
    inc %x
  }
}
#toplist on
on *:text:*:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  mkdir $+(",$scriptdirtoplist,")
  if (!$hget($+(words_,$network,_,$chan))) {
    hmake $+(words_,$network,_,$chan) 10000
    hmake $+(letters_,$network,_,$chan) 10000
    hmake $+(smilies_,$network,_,$chan) 10000
    hmake $+(places_,$network,_,$chan) 10000
  }
  if ($hget($+(words_,$network,_,$chan),$mask($fulladdress,11))) {
    set %words_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ] $ifmatch
    set %places_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ] $hget($+(places_,$network,_,$chan),$mask($fulladdress,11)) 
    set %smilies_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ] $hget($+(smilies_,$network,_,$chan),$mask($fulladdress,11))
    set %letters_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ] $hget($+(letters_,$network,_,$chan),$mask($fulladdress,11))
    hdel $+(places_,$network,_,$chan) $mask($fulladdress,11)
    hdel $+(words_,$network,_,$chan) $mask($fulladdress,11)
    hdel $+(smilies_,$network,_,$chan) $mask($fulladdress,11)
    hdel $+(letters_,$network,_,$chan) $mask($fulladdress,11)
    hadd $+(places_,$network,_,$chan) $mask($fulladdress,11) $gettok(%places_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],1,32) $calc($gettok(%places_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],2,32) + $numtok($1-,32))
    hadd $+(words_,$network,_,$chan) $mask($fulladdress,11) $gettok(%words_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],1,32) $calc($gettok(%words_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],2,32) + $numtok($1-,32))
    hadd $+(letters_,$network,_,$chan) $mask($fulladdress,11) $gettok(%letters_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],1,32) $calc($gettok(%letters_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],2,32) + $len($remove($1-,$chr(32))))
    hadd $+(smilies_,$network,_,$chan) $mask($fulladdress,11) $gettok(%smilies_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],1,32) $calc($gettok(%smilies_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],2,32) + $calc($hget($+(smilies_,$network,_,$chan),$mask($fulladdress,11)) + $regex($1-,/(\:|;)(-)?(P|X|D|\/|\\|\[|\])/ig) + $count($1-,: $+ $chr(40),:- $+ $chr(40),: $+ $chr(41),:- $+ $chr(41),; $+ $chr(40),;- $+ $chr(40),; $+ $chr(41),;- $+ $chr(41))))
    unset %words_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ]
    unset %places_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ]
    unset %smilies_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ]
    unset %letters_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ]  
  }
  else {
    hadd $+(places_,$network,_,$chan) $mask($fulladdress,11) $nick $calc($hget($+(places_,$network,_,$chan),$mask($fulladdress,11)) + $numtok($1-,32))
    hadd $+(words_,$network,_,$chan) $mask($fulladdress,11) $nick $calc($hget($+(words_,$network,_,$chan),$mask($fulladdress,11)) + $numtok($1-,32))
    hadd $+(letters_,$network,_,$chan) $mask($fulladdress,11) $nick $calc($hget($+(letters_,$network,_,$chan),$mask($fulladdress,11)) + $len($remove($1-,$chr(32))))
    hadd $+(smilies_,$network,_,$chan) $mask($fulladdress,11) $nick $calc($hget($+(smilies_,$network,_,$chan),$mask($fulladdress,11)) + $calc($regex($1-,/(\:|;)(-)?(P|X|D|\/|\\|\[|\])/ig) + $count($1-,: $+ $chr(40),:- $+ $chr(40),: $+ $chr(41),:- $+ $chr(41),; $+ $chr(40),;- $+ $chr(40),; $+ $chr(41),;- $+ $chr(41))))
  }
  if (!$hget($+(today_words_,$network,_,$chan))) {
    hmake $+(today_words_,$network,_,$chan) 10000
    hmake $+(today_letters_,$network,_,$chan) 10000
    hmake $+(today_smilies_,$network,_,$chan) 10000
    hmake $+(today_places_,$network,_,$chan) 10000
  }
  if ($hget($+(today_words_,$network,_,$chan),$mask($fulladdress,11))) {
    set %today_words_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ] $ifmatch
    set %today_places_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ] $hget($+(today_places_,$network,_,$chan),$mask($fulladdress,11)) 
    set %today_smilies_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ] $hget($+(today_smilies_,$network,_,$chan),$mask($fulladdress,11))
    set %today_letters_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ] $hget($+(today_letters_,$network,_,$chan),$mask($fulladdress,11))
    hdel $+(today_places_,$network,_,$chan) $mask($fulladdress,11)
    hdel $+(today_words_,$network,_,$chan) $mask($fulladdress,11)
    hdel $+(today_smilies_,$network,_,$chan) $mask($fulladdress,11)
    hdel $+(today_letters_,$network,_,$chan) $mask($fulladdress,11)
    hadd $+(today_places_,$network,_,$chan) $mask($fulladdress,11) $gettok(%today_places_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],1,32) $calc($gettok(%today_places_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],2,32) + $numtok($1-,32))
    hadd $+(today_words_,$network,_,$chan) $mask($fulladdress,11) $gettok(%today_words_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],1,32) $calc($gettok(%today_words_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],2,32) + $numtok($1-,32))
    hadd $+(today_letters_,$network,_,$chan) $mask($fulladdress,11) $gettok(%today_letters_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],1,32) $calc($gettok(%today_letters_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],2,32) + $len($remove($1-,$chr(32))))
    hadd $+(today_smilies_,$network,_,$chan) $mask($fulladdress,11) $gettok(%today_smilies_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],1,32) $calc($gettok(%today_smilies_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ],2,32) + $calc($hget($+(today_smilies_,$network,_,$chan),$mask($fulladdress,11)) + $regex($1-,/(\:|;)(-)?(P|X|D|\/|\\|\[|\])/ig) + $count($1-,: $+ $chr(40),:- $+ $chr(40),: $+ $chr(41),:- $+ $chr(41),; $+ $chr(40),;- $+ $chr(40),; $+ $chr(41),;- $+ $chr(41))))
    unset %today_words_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ]
    unset %today_places_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ]
    unset %today_smilies_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ]
    unset %today_letters_ [ $+ [ $network ] [ $+ . $+ [ $chan ] [ $+ . $+ [ $nick ] ] ] ]  
  }
  else {
    hadd $+(today_places_,$network,_,$chan) $mask($fulladdress,11) $nick $calc($hget($+(today_places_,$network,_,$chan),$mask($fulladdress,11)) + $numtok($1-,32))
    hadd $+(today_words_,$network,_,$chan) $mask($fulladdress,11) $nick $calc($hget($+(today_words_,$network,_,$chan),$mask($fulladdress,11)) + $numtok($1-,32))
    hadd $+(today_letters_,$network,_,$chan) $mask($fulladdress,11) $nick $calc($hget($+(today_letters_,$network,_,$chan),$mask($fulladdress,11)) + $len($remove($1-,$chr(32))))
    hadd $+(today_smilies_,$network,_,$chan) $mask($fulladdress,11) $nick $calc($hget($+(today_smilies_,$network,_,$chan),$mask($fulladdress,11)) + $calc($regex($1-,/(\:|;)(-)?(P|X|D|\/|\\|\[|\])/ig) + $count($1-,: $+ $chr(40),:- $+ $chr(40),: $+ $chr(41),:- $+ $chr(41),; $+ $chr(40),;- $+ $chr(40),; $+ $chr(41),;- $+ $chr(41))))
  }
  updatelist $network $chan $mask($fulladdress,11) $nick lines
  updatelist $network $chan $mask($fulladdress,11) $nick today_lines  
  if ($1- = !top10) { msg $chan $toplist($network,$chan,words,1) }
  elseif ($1 = !top10 && $regex($2-,/^(words|letters|smilies|lines|actions|modes|joins|parts|kicks|notices|topics|ctcps|timewasted)$/i)) { msg $chan $toplist($network,$chan,$regml(1),1) }
  elseif ($1- = !top20) { msg $chan $toplist($network,$chan,words,2) }
  elseif ($1 = !top20 && $regex($2-,/^(words|letters|smilies|lines|actions|modes|joins|parts|kicks|notices|topics|ctcps|timewasted)$/i)) { msg $chan $toplist($network,$chan,$regml(1),2) }
  elseif ($1- = !todaytop10) { msg $chan $toplist($network,$chan,today_words,1) }
  elseif ($1 = !todaytop10 && $regex($2-,/^(words|letters|smilies|lines|actions|modes|joins|parts|kicks|notices|topics|ctcps|timewasted)$/i)) { msg $chan $toplist($network,$chan,$+(today_,$regml(1)),1) }
  elseif ($1- = !todaytop20) { msg $chan $toplist($network,$chan,today_words,2) }
  elseif ($1 = !todaytop20 && $regex($2-,/^(words|letters|smilies|lines|actions|modes|joins|parts|kicks|notices|topics|ctcps|timewasted)$/i)) { msg $chan $toplist($network,$chan,$+(today_,$regml(1)),2) }  
  elseif ($1- = !stat) { msg $chan $statlist($network,$chan,$mask($fulladdress,11),$nick) }
  elseif ($1 = !stat && $numtok($2-,32) = 1) { msg $chan $statlist($network,$chan,$address($2,11),$2) }
  elseif ($1- = !place) { msg $chan $placelist($network,$chan,$mask($fulladdress,11),$nick) }
  elseif ($1 = !place && $numtok($2-,32) = 1) { msg $chan $placelist($network,$chan,$mask($fulladdress,11),$2) }
  elseif ($1- = !todaystat) { msg $chan $statlist($network,$chan,$mask($fulladdress,11),$nick,1) }
  elseif ($1 = !todaystat && $numtok($2-,32) = 1) { msg $chan $statlist($network,$chan,$address($2,11),$2,1) }
  elseif ($1- = !todayplace) { msg $chan $placelist($network,$chan,$mask($fulladdress,11),$nick,1) }
  elseif ($1 = !todayplace && $numtok($2-,32) = 1) { msg $chan $placelist($network,$chan,$mask($fulladdress,11),$2,1) }  
  elseif ($1- = !tophelp) { notice $nick supported commands; !top10 or !top20 or !todaytop10 or !todaytop20 [words|letters|smilies|lines|actions|modes|joins|parts|kicks|notices|topics|ctcps|timewasted], !stat or !todaystat [nick], !place or !todayplace [nick] }
  elseif ($1 = !top10 && $2) { msg $chan No such stat type }
  elseif ($1 = !top20 && $2) { msg $chan No such stat type }
  elseif ($1 = !todaytop10 && $2) { msg $chan No such stat type }
  elseif ($1 = !todaytop20 && $2) { msg $chan No such stat type }
}
#toplist end
#topctcps on
ctcp *:*:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick ctcps
  updatelist $network $chan $mask($fulladdress,11) $nick today_ctcps
}
#topctcps end
#topnotices on
on *:notice:*:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick notices
  updatelist $network $chan $mask($fulladdress,11) $nick today_notices
}
#topnotices end
#toptopics on
on *:topic:%topchannels: {
  if ($nick = $me) return
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick topics
  updatelist $network $chan $mask($fulladdress,11) $nick today_topics
}
#toptopics end
#topmodes on
on *:ban:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick modes
  updatelist $network $chan $mask($fulladdress,11) $nick today_modes
}
on *:unban:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick modes
  updatelist $network $chan $mask($fulladdress,11) $nick today_modes
}
on *:op:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick modes
  updatelist $network $chan $mask($fulladdress,11) $nick today_modes
}
on *:deop:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick modes
  updatelist $network $chan $mask($fulladdress,11) $nick today_modes
}
on *:voice:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick modes
  updatelist $network $chan $mask($fulladdress,11) $nick today_modes
}
on *:devoice:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick modes
  updatelist $network $chan $mask($fulladdress,11) $nick today_modes
}
on *:mode:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick modes
  updatelist $network $chan $mask($fulladdress,11) $nick today_modes
}
#topmodes end
#topactions on
on *:action:*:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick actions
  updatelist $network $chan $mask($fulladdress,11) $nick today_actions
}
#topactions end
#topjoins on
on *:join:%topchannels: {
  who $chan
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick joins
  updatelist $network $chan $mask($fulladdress,11) $nick today_joins
  .timer $+ $+($network,.,$chan,.,$nick) 0 1 timelist $network $chan $mask($fulladdress,11) $nick
}
#topjoins end
#topparts on
on *:part:%topchannels: {
  if ($nick = $me) {
    .timer $+ $+(*,$chan,*) off
    return
  }
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick parts
  updatelist $network $chan $mask($fulladdress,11) $nick today_parts
  .timer $+ $+($network,.,$chan,.,$nick) off
}
#topparts end
#topkicks on
on *:kick:%topchannels: {
  if ($nick = $me) return
  if (!$timer(checktodaylist)) .timerchecktodaylist 0 1 checktodaylist
  updatenl
  updatelist $network $chan $mask($fulladdress,11) $nick kicks
  updatelist $network $chan $mask($fulladdress,11) $nick today_kicks
  .timer $+ $+($network,.,$chan,.,$nick) off
}
#topkicks end
alias -l toplist {
  var %.a = $+($3,_,$1,_,$2), %.b = 1, %.c = $gettok($hget(%.a,$hget(%.a,%.b).item),2,32), %.d = 1, %.e = $gettok($hget(%.a,$hget(%.a,%.b).item),1,32), %.f = 1, %.h = $hget(%.a,%.b).item
  :loop
  while (%.b <= $hget(%.a,0).item) {
    if ($gettok($hget(%.a,$hget(%.a,$calc(%.b + 1)).item),2,32) > %.c) {
      var %.c = $ifmatch, %.e = $gettok($hget(%.a,$hget(%.a,$calc(%.b + 1)).item),1,32), %.h = $hget(%.a,$calc(%.b + 1)).item
    }
    inc %.b
  }
  var %.g = $addtok(%.g,$+($ord(%.f),.,$chr(32),%.e,$chr(40),%.c,$chr(41)),32) 
  if (!$hget($+(temp_,$3,_,$1,_,$2))) {
    hmake $+(temp_,$3,_,$1,_,$2) 10000
  }
  if (%.c) {
    hadd $+(temp_,$3,_,$1,_,$2) %.h %.e %.c
    hdel %.a %.h
  }  
  if ($hget(%.a,0).item > 0 && %.f < 20) {
    var %.b = 1, %.c = $gettok($hget(%.a,$hget(%.a,%.b).item),2,32), %.e = $gettok($hget(%.a,$hget(%.a,%.b).item),1,32), %.h = $hget(%.a,%.b).item
    inc %.f    
    goto loop
  }
  while (%.d <= $hget($+(temp_,$3,_,$1,_,$2),0).item) {
    hadd %.a $hget($+(temp_,$3,_,$1,_,$2),%.d).item $hget($+(temp_,$3,_,$1,_,$2),$hget($+(temp_,$3,_,$1,_,$2),%.d).item)
    inc %.d
  }
  hfree $+(temp_,$3,_,$1,_,$2)
  if (%.c) {
    return $iif(today isin $3,[TODAY],[GLOBAL]) $+($iif($4 = 1,Top10,$iif($4 = 2,Top20)),$chr(40),$upper($left($remove($3,today_),1)),$lower($right($remove($3,today_),-1)),$chr(41),:) $iif($4 = 1,$iif($gettok(%.g,1-20,32),$ifmatch,nobody),$iif($4 = 2,$iif($gettok(%.g,21-40,32),$ifmatch,nobody)))
  }
  else {
    return $iif(today isin $3,[TODAY],[GLOBAL]) $+($iif($4 = 1,Top10,$iif($4 = 2,Top20)),$chr(40),$upper($left($remove($3,today_),1)),$lower($right($remove($3,today_),-1)),$chr(41),:) nobody
  }
}
alias -l placelist {
  write -c $+(",$scriptdirtoplist\sort_,$iif($5,today_),$1,_,$2,.txt,")
  var %.a = $+($iif($5,today_),places_,$1,_,$2), %.b = 1, %.c = $gettok($hget(%.a,$hget(%.a,%.b).item),2,32), %.d = 1, %.e = $gettok($hget(%.a,$hget(%.a,%.b).item),1,32), %.f = 1, %.g = $hget(%.a,%.b).item
  :loop
  while (%.b <= $hget(%.a,0).item) {
    if ($gettok($hget(%.a,$hget(%.a,$calc(%.b + 1)).item),2,32) > %.c) {
      var %.c = $ifmatch, %.e = $gettok($hget(%.a,$hget(%.a,$calc(%.b + 1)).item),1,32), %.g = $hget(%.a,$calc(%.b + 1)).item
    }
    inc %.b
  }
  write $+(",$scriptdirtoplist\sort_,$iif($5,today_),$1,_,$2,.txt,") %.e
  if (!$hget($+(temp_,$iif($5,today_),places_,$1,_,$2))) {
    hmake $+(temp_,$iif($5,today_),places_,$1,_,$2) 10000
  }
  hadd $+(temp_,$iif($5,today_),places_,$1,_,$2) %.g %.e %.c
  hdel %.a %.g
  if ($hget(%.a,0).item > 0) {
    var %.b = 1, %.c = $gettok($hget(%.a,$hget(%.a,%.b).item),2,32), %.e = $gettok($hget(%.a,$hget(%.a,%.b).item),1,32), %.g = $hget(%.a,%.b).item
    inc %.f    
    goto loop
  }
  while (%.d <= $hget($+(temp_,$iif($5,today_),places_,$1,_,$2),0).item) {
    hadd %.a $hget($+(temp_,$iif($5,today_),places_,$1,_,$2),%.d).item $hget($+(temp_,$iif($5,today_),places_,$1,_,$2),$hget($+(temp_,$iif($5,today_),places_,$1,_,$2),%.d).item)
    inc %.d
  }
  hfree $+(temp_,$iif($5,today_),places_,$1,_,$2)
  var %x = 1
  while (%x <= $lines($+(",$scriptdirtoplist\sort_,$iif($5,today_),$1,_,$2,.txt,"))) {
    if ($4 = $read($+(",$scriptdirtoplist\sort_,$iif($5,today_),$1,_,$2,.txt,"),%x)) {
      return $iif($5,[TODAY],[GLOBAL]) $4 is on place $chr(35) $+ $readn out of $hget(%.a,0).item
    }
    inc %x
  }
  return Sorry, I don't have any stats about $4 in $2
}
alias -l statlist {
  if ($hget($+($iif($5,today_),words_,$1,_,$2),$3)) {
    return $iif($5,[TODAY],[GLOBAL]) $gettok($hget($+($iif($5,today_),words_,$1,_,$2),$3),1,32) $+ : $gettok($hget($+($iif($5,today_),words_,$1,_,$2),$3),2,32) words, $gettok($hget($+($iif($5,today_),letters_,$1,_,$2),$3),2,32) letters, $gettok($hget($+($iif($5,today_),smilies_,$1,_,$2),$3),2,32) smilies, time wasted: $replace($duration($gettok($hget($+($iif($5,today_),timewasted_,$1,_,$2),$3),2,32)),sec,$chr(32) $+ second,min,$chr(32) $+ minute,hr,$chr(32) $+ hour,day,$chr(32) $+ day,wk,$chr(32) $+ week) $iif(!$gettok($hget($+($iif($5,today_),timewasted_,$1,_,$2),$3),2,32),0 seconds)
  }
  else {
    return Sorry, I don't have any stats about $4 in $2
  }
}
alias -l timelist {
  updatenl
  if (!$hget($+(timewasted_,$1,_,$2))) {
    hmake $+(timewasted_,$1,_,$2) 10000
  }
  if ($hget($+(timewasted_,$1,_,$2),$3)) {
    set %timewasted_ [ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ] $ifmatch
    hdel $+(timewasted_,$1,_,$2) $3
    hadd $+(timewasted_,$1,_,$2) $3 $gettok(%timewasted_ [ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ],1,32) $calc($gettok(%timewasted_ [ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ],2,32) + 1)
    unset %timewasted_ [ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ]
  }
  else {
    hadd $+(timewasted_,$1,_,$2) $3 $4 $calc($hget($+(timewasted_,$1,_,$2),$3) + 1)
  }
  if (!$hget($+(today_timewasted_,$1,_,$2))) {
    hmake $+(today_timewasted_,$1,_,$2) 10000
  }
  if ($hget($+(today_timewasted_,$1,_,$2),$3)) {
    set %today_timewasted_ [ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ] $ifmatch
    hdel $+(today_timewasted_,$1,_,$2) $3
    hadd $+(today_timewasted_,$1,_,$2) $3 $gettok(%today_timewasted_ [ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ],1,32) $calc($gettok(%today_timewasted_ [ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ],2,32) + 1)
    unset %today_timewasted_ [ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ]
  }
  else {
    hadd $+(today_timewasted_,$1,_,$2) $3 $4 $calc($hget($+(today_timewasted_,$1,_,$2),$3) + 1)
  }
}
alias -l updatelist {
  if (!$hget($+($5,_,$1,_,$2))) {
    hmake $+($5,_,$1,_,$2) 10000
  }
  if ($hget($+($5,_,$1,_,$2),$3)) {
    set % [ $+ [ $5 ] [ $+ _ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ] ] $ifmatch
    hdel $+($5,_,$1,_,$2) $3
    hadd $+($5,_,$1,_,$2) $3 $gettok(% [ $+ [ $5 ] [ $+ _ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ] ],1,32) $calc($gettok(% [ $+ [ $5 ] [ $+ _ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ] ],2,32) + 1)
    unset % [ $+ [ $5 ] [ $+ _ $+ [ $1 ] [ $+ . $+ [ $2 ] [ $+ . $+ [ $4 ] ] ] ] ]
  }
  else {
    hadd $+($5,_,$1,_,$2) $3 $4 $calc($hget($+($5,_,$1,_,$2),$3) + 1)
  }
}
alias -l checktodaylist {
  if ($time = 00:00:00) {
    hfree -w $+(*,today,*)
  }
}

;EOF