; ******************************************************
; DC mBOT - Top10 Bot
; ******************************************************
on *:Text:*:#: {
if (%Extra-Set == OFF) || (%Top10 != ON) || ($nick == $me) return
if ($1 == %Trigger $+ top10) {
if (%Top10-Flood. [ $+ [ $chan ] ] >= 2) {
if (!%Top10-Halted. [ $+ [ $chan ] ]) { msg $chan The Top10 can respond for only 2 trigger within a minute. | set -u30 %Top10-Halted. [ $+ [ $chan ] ] Yes }
return
}
inc -u60 %Top10-Flood. [ $+ [ $chan ] ] 1
if ($lines($DC.Dir(mBOT\ChanStats.dat)) > 1) {
msg $chan $Top10.MakeTop10($network $+ @ $+ $chan)
unset %stats_top10_*
window -c @top10source
}
else { msg $chan There is no record in Top10's database. | return }
}
if ($1 == %Trigger $+ ttop10) {
inc -u60 %Top10-Flood 1
if ($lines($DC.Dir(mBOT\ChanStats.dat)) > 1) {
msg $chan $Top10.MakeTodayTop10($network $+ @ $+ $chan)
unset %stats_top10_*
window -c @top10source
}
else { msg $chan There is no record in Today-Top10's database. | return }
}
if ($1 == %Trigger $+ stats) {
if (%Top10-Flood. [ $+ [ $chan ] ] >= 2) {
if (!%Top10-Halted. [ $+ [ $chan ] ]) { msg $chan The Top10 can respond for only 2 trigger within a minute. | set -u30 %Top10-Halted. [ $+ [ $chan ] ] Yes }
return
}
inc -u60 %Top10-Flood. [ $+ [ $chan ] ] 1
msg $chan $Top10.Getstats($network $+ @ $+ $chan $+ @ $+ $iif($2,$2,$nick))
}
if ($1 == %Trigger $+ tstats) {
if (%Top10-Flood. [ $+ [ $chan ] ] >= 2) {
if (!%Top10-Halted. [ $+ [ $chan ] ]) { msg $chan The Top10 can respond for only 2 trigger within a minute. | set -u30 %Top10-Halted. [ $+ [ $chan ] ] Yes }
return
}
inc -u60 %Top10-Flood. [ $+ [ $chan ] ] 1
msg $chan $Top10.GetTodayStats($network $+ @ $+ $chan $+ @ $+ $iif($2,$2,$nick))
}
if ($1 == %Trigger $+ delstats) && ($2) && ($nick == %Owner-DC.mBOT || $Cown-Check($nick) || $nick == $2) {
Top10.RemoveNickStat $network $+ @ $+ $chan $+ @ $+ $2
msg $chan Erasing entries for Nick: $2
}
if ($1 == %Trigger $+ clearstats) && ($nick == %Owner-DC.mBOT || $Cown-Check($nick)) {
Top10.RemoveChannelStat $network $+ @ $+ $chan
msg $chan $chan Stats has been erased.
}
if ($left($1,1) == %Trigger) {
hinc -m totalcommands $network $+ @ $+ $chan $+ @ $+ $nick 1
hinc -m todaytotalcommands $network $+ @ $+ $chan $+ @ $+ $nick 1
}
hinc -m totalwords $network $+ @ $+ $chan $+ @ $+ $nick $numtok($1-,32)
hinc -m totalletters $network $+ @ $+ $chan $+ @ $+ $nick $len($1-)
hinc -m totallines $network $+ @ $+ $chan $+ @ $+ $nick 1
hinc -m todaytotalwords $network $+ @ $+ $chan $+ @ $+ $nick $numtok($1-,32)
hinc -m todaytotalletters $network $+ @ $+ $chan $+ @ $+ $nick $len($1-)
hinc -m todaytotallines $network $+ @ $+ $chan $+ @ $+ $nick 1
}
on *:Action:*:#: {
if (%Top10 == ON) {
hinc -m totalactions $network $+ @ $+ $chan $+ @ $+ $nick 1
hinc -m totalwords $network $+ @ $+ $chan $+ @ $+ $nick $numtok($1-,32)
hinc -m totalletters $network $+ @ $+ $chan $+ @ $+ $nick $len($1-)
hinc -m todaytotalactions $network $+ @ $+ $chan $+ @ $+ $nick 1
hinc -m todaytotalwords $network $+ @ $+ $chan $+ @ $+ $nick $numtok($1-,32)
hinc -m todaytotalletters $network $+ @ $+ $chan $+ @ $+ $nick $len($1-)
}
}
on *:Start: {
Top10.LoadStats
if (!%Top10) { set %Top10 ON }
.timer.resettodaystats 0:00 1 1 /Top10.DailyStatsFlush
}
on *:Exit: { Top10.SaveStats }
alias Top10.SaveStats {
hsave -i totalwords $DC.Dir(mBOT\ChanStats.dat) totalwords
hsave -i totalletters $DC.Dir(mBOT\ChanStats.dat) totalletters
hsave -i totalcommands $DC.Dir(mBOT\ChanStats.dat) totalcommands
hsave -i totalactions $DC.Dir(mBOT\ChanStats.dat) totalactions
hsave -i totallines $DC.Dir(mBOT\ChanStats.dat) totallines
}
alias Top10.ClearTodayStats {
.hfree -w todaytotal*
.hmake todaytotalwords 20
.hmake todaytotalletters 20
.hmake todaytotalcommands 20
.hmake todaytotalactions 20
.hmake todaytotallines 20
}
alias Top10.LoadStats {
.hmake totalwords 20
.hmake totalletters 20
.hmake totalcommands 20
.hmake totalactions 20
.hmake totallines 20
.hload -i totalwords $DC.Dir(mBOT\ChanStats.dat) totalwords
.hload -i totalletters $DC.Dir(mBOT\ChanStats.dat) totalletters
.hload -i totalcommands $DC.Dir(mBOT\ChanStats.dat) totalcommands
.hload -i totalactions $DC.Dir(mBOT\ChanStats.dat) totalactions
.hload -i totallines $DC.Dir(mBOT\ChanStats.dat) totallines
}
alias Top10.ClearStats {
;var %stats_clearconfirm = $input(Are you sure? you want to wipe whole Statistics Database?,yvqd,Channel Top10)
;if (%stats_clearconfirm == $yes) {
.hfree -w total*
.hmake totalwords 20
.hmake totalletters 20
.hmake totalcommands 20
.hmake totalactions 20
.hmake totallines 20
Top10.ClearTodayStats
; }
}
alias Top10.RemoveNickStat {
var %stats-remnick = $1 $+ *
if ($hget(totalwords)) { hdel -w totalwords %stats-remnick }
if ($hget(totalletters)) { hdel -w totalletters %stats-remnick }
if ($hget(totalcommands)) { hdel -w totalcommands %stats-remnick }
if ($hget(totalactions)) { hdel -w totalactions %stats-remnick }
if ($hget(totallines)) { hdel -w totallines %stats-remnick }
Top10.SaveStats
}
alias Top10.RemoveChannelStat {
var %stats-remchan = $1 $+ *
if ($hget(totalwords)) { hdel -w totalwords %stats-remchan }
if ($hget(totalletters)) { hdel -w totalletters %stats-remchan }
if ($hget(totalcommands)) { hdel -w totalcommands %stats-remchan }
if ($hget(totalactions)) { hdel -w totalactions %stats-remchan }
if ($hget(totallines)) { hdel -w totallines %stats-remchan }
if ($hget(todaytotalwords)) { hdel -w todaytotalwords %stats-remchan }
if ($hget(todaytotalletters)) { hdel -w todaytotalletters %stats-remchan }
if ($hget(todaytotalcommands)) { hdel -w todaytotalcommands %stats-remchan }
if ($hget(todaytotalactions)) { hdel -w todaytotalactions %stats-remchan }
if ($hget(todaytotallines)) { hdel -w todaytotallines %stats-remchan }
Top10.SaveStats
}
alias Top10.Getstats {
if ($hget(totalwords, $1)) {
if ($hget(totalwords, $1)) { var %t.words = $hget(totalwords, $1) }
else { var %t.words = 0 }
if ($hget(totalletters, $1)) { var %t.letters = $hget(totalletters, $1) }
else { var %t.letters = 0 }
if ($hget(totalcommands, $1)) { var %t.commands = $hget(totalcommands, $1) }
else { var %t.commands = 0 }
if ($hget(totallines, $1)) { var %t.lines = $hget(totallines, $1) }
else { var %t.lines = 0 }
if ($hget(totalactions, $1)) { var %t.actions = $hget(totalactions, $1) }
else { var %t.actions = 0 }
return [ $+ $gettok($1,3,64) $+ ] Spoken Words: %t.words ( $+ %t.letters Letters) Commands Used %t.commands $+ . %t.lines Lines and %t.actions Actions.
}
return I Have No Stats About $gettok($1,3,64)
}
alias Top10.GetTodayStats {
if ($hget(todaytotalwords, $1)) {
if ($hget(todaytotalwords, $1)) { var %t.words = $hget(todaytotalwords, $1) }
else { var %t.words = 0 }
if ($hget(todaytotalletters, $1)) { var %t.letters = $hget(todaytotalletters, $1) }
else { var %t.letters = 0 }
if ($hget(todaytotalcommands, $1)) { var %t.commands = $hget(todaytotalcommands, $1) }
else { var %t.commands = 0 }
if ($hget(todaytotallines, $1)) { var %t.lines = $hget(todaytotallines, $1) }
else { var %t.lines = 0 }
if ($hget(todaytotalactions, $1)) { var %t.actions = $hget(todaytotalactions, $1) }
else { var %t.actions = 0 }
return [ $+ $gettok($1,3,64) $+ ] Spoken Words Today: %t.words ( $+ %t.letters Letters) Commands Used Today %t.commands $+ . %t.lines Lines and %t.actions Actions.
}
return I have no stats about $gettok($1,3,64)
}
alias Top10.MakeTop10 {
Top10.SaveStats
window @top10source
clear @top10source
if ($lines($DC.Dir(mBOT\ChanStats.dat)) > 1) {
var %stats_findbegin = $read($DC.Dir(mBOT\ChanStats.dat), s, [totalwords])
var %stats_looppoint = $calc($readn + 1)
while (!%stats_loophalt) {
var %stats_putline = $read($DC.Dir(mBOT\ChanStats.dat), %stats_looppoint)
if ($left(%stats_putline,1) != $chr(91)) && ($left(%stats_putline,$len($1)) == $1) {
var %statscleanline = $gettok($read($DC.Dir(mBOT\ChanStats.dat), %stats_looppoint),3,64)
aline @top10source %statscleanline
}
elseif ($left(%stats_putline,1) == $chr(91)) { var %stats_loophalt = true }
inc %stats_looppoint
}
filter -cetuww 2 61 @top10source @top10source *
var %stats_loop10 = 1
while (!%statssecondloophalt) {
if ($line(@top10source, %stats_loop10)) {
set -e %stats_top10_ [ $+ [ %stats_loop10 ] ] $gettok($line(@top10source, %stats_loop10),1,61) ( $+ $gettok($line(@top10source, %stats_loop10),2,61) $+ )
inc %stats_loop10
}
if (!$line(@top10source, %stats_loop10)) || (%stats_loop10 == 10) { var %statssecondloophalt = true }
}
if ($calc(%stats_loop10 - 1) == 0) return There is no record in Top10's database.
return $+(Top,$calc(%stats_loop10 - 1),,$chr(32),Chatters by Total Spoken Words:,$chr(32)) $iif(%stats_top10_1, 1st: %stats_top10_1) $iif(%stats_top10_2, 2nd: %stats_top10_2) $iif(%stats_top10_3, 3rd: %stats_top10_3) $iif(%stats_top10_4, 4th: %stats_top10_4) $iif(%stats_top10_5, 5th: %stats_top10_5) $iif(%stats_top10_6, 6th: %stats_top10_6) $iif(%stats_top10_7, 7th: %stats_top10_7) $iif(%stats_top10_8, 8th: %stats_top10_8) $iif(%stats_top10_9, 9th: %stats_top10_9) $iif(%stats_top10_10, 10th: %stats_top10_10)
}
}
alias Top10.MakeTodayTop10 {
window @top10source
clear @top10source
hsave -i todaytotalwords $DC.Dir(mBOT\TempStats.dat) totalwords
if ($lines($DC.Dir(mBOT\ChanStats.dat)) > 1) {
var %stats_loopline = 1
while (%stats_loopline <= $lines($DC.Dir(mBOT\TempStats.dat))) {
if ($gettok($read($DC.Dir(mBOT\TempStats.dat),%stats_loopline),1,64) == $gettok($1,1,64)) && ($gettok($read($DC.Dir(mBOT\TempStats.dat),%stats_loopline),2,64) == $gettok($1,2,64)) {
aline -p @top10source $gettok($read($DC.Dir(mBOT\TempStats.dat),%stats_loopline),3,64)
}
inc %stats_loopline
}
filter -cetuww 2 61 @top10source @top10source *
var %stats_loop10 = 1
while (!%statssecondloophalt) {
if ($line(@top10source, %stats_loop10)) {
set -e %stats_top10_ [ $+ [ %stats_loop10 ] ] $gettok($line(@top10source, %stats_loop10),1,61) ( $+ $gettok($line(@top10source, %stats_loop10),2,61) $+ )
inc %stats_loop10
}
if (!$line(@top10source, %stats_loop10)) || (%stats_loop10 < 11) { var %statssecondloophalt = true }
}
.remove $DC.Dir(mBOT\TempStats.dat)
if ($calc(%stats_loop10 - 1) == 0) return There is no record in Today-Top10's database.
return $+(Today's Top,,$calc(%stats_loop10 - 1), ,$chr(32),Chatters by Total Spoken Words:,$chr(32)) $iif(%stats_top10_1, 1st: %stats_top10_1) $iif(%stats_top10_2, 2nd: %stats_top10_2) $iif(%stats_top10_3, 3rd: %stats_top10_3) $iif(%stats_top10_4, 4th: %stats_top10_4) $iif(%stats_top10_5, 5th: %stats_top10_5) $iif(%stats_top10_6, 6th: %stats_top10_6) $iif(%stats_top10_7, 7th: %stats_top10_7) $iif(%stats_top10_8, 8th: %stats_top10_8) $iif(%stats_top10_9, 9th: %stats_top10_9) $iif(%stats_top10_10, 10th: %stats_top10_10)
}
}
alias Top10.DailyStatsFlush {
.timer.resettodaystats 0:00 /Top10.DailyStatsFlush
Top10.ClearTodayStats
if ($server) { amsg Resetting Today's Top10 statistics - It's Midnight here... }
}