StatsSuite/ 40755 766 144 0 6156175765 11751 5ustar babbosusersStatsSuite/stats.core.tcl100644 766 144 25210 6155433522 14642 0ustar babbosusers # stats - statistic user records of channels # first char typed on 4th of may 97 ... #set where you want the stats and the kick/join files to be stored... set st_file "text/stat" set kick_file "text/kickjoins" #set when you want the stats day to close (time zones differ) set closeday "07:00" ######################################################################## # Thats all you had to setup, no need touch anything from here... # ######################################################################## # check if stats file exists...if not create one if {![file exists $st_file]} { set cr8file [open $st_file w] puts $cr8file "HIGHEST 0 [unixtime]" puts $cr8file "DAYSWITCH 0" puts $cr8file "DAY_AVG 0 Sun 01 May 0 0" puts $cr8file "HR_AVG 00 1 [unixtime] 0 0" puts $cr8file "MONTH_AVG 1 Jan 1666" close $cr8file } #after checkin if the file exists, check if its contents are as they should be putlog "Channel Stats Suite  loaded! |V1.0| by BaBBoS" proc clean_up_stats_file {} { global st_file set highestt 0 set houravg 0 set dayaver 0 set mo_mina 0 set fsol [open $st_file r] while {![eof $fsol]} { set explosives [gets $fsol] if {[eof $fsol]} {break} set we_have [lindex $explosives 0] if {$we_have == "HIGHEST"} {incr highestt} if {$we_have == "HR_AVG"} {incr houravg} if {$we_have == "DAY_AVG"} {incr dayaver} if {$we_have == "MONTH_AVG"} {incr mo_mina} } close $fsol if {$mo_mina > 12} { set cutem [expr $mo_mina -1] clean_up MONTH_AVG $cutem } if {$highestt > 1} { set cutem [expr $highestt - 1] clean_up HIGHEST $cutem } if {$houravg > 23 } { set cutem [expr $houravg - 23] clean_up HR_AVG $cutem } if {$dayaver > 30 } { set cutem [expr $dayaver - 30] clean_up DAY_AVG $cutem } return 1 unset mo_mina highestt houravg dayaver cutem } #thats an ''internal'' procedure to the previous one...it actually #removes all the Xcess entries in the stats file proc clean_up {cutwhat howmany} { global st_file putlog " Excess '$cutwhat' Entries detected ($howmany) ... Cleared !!" set fabio [open $st_file r] set fantasy [open "${st_file}~tmp" w] while {![eof $fabio]} { set krap [gets $fabio] if {[eof $fabio]} {break} set leeroy [lindex $krap 0] if {$leeroy != $cutwhat } { puts $fantasy $krap } else { if {$howmany < 1} {puts $fantasy $krap} if {$howmany > 0} {set howmany [expr $howmany - 1 ] } } } close $fantasy close $fabio exec /bin/mv ${st_file}~tmp $st_file } #and here iz where we execute the above two procedures :) clean_up_stats_file ##################################################################### #reseting the global variables... set min_cnt 0 set cur_day_avg 0 set curavg 0 set summoner 0 set hourtog 0 set daytog 0 set monthtog 0 #restoring from the file all the global valuezzz set jericho [open $st_file r] while {![eof $jericho]} { set panoramix [gets $jericho] if {[eof $jericho]} {break} set hhcore [lindex $panoramix 0] if {$hhcore == "HIGHEST"} { set highest_hr_avg [lindex $panoramix 1] } if {$hhcore == "MONTH_AVG"} { set cur_month_avg [lindex $panoramix 1]} incr monthtog if {$hhcore == "DAY_AVG"} { set cur_day_avg [lindex $panoramix 1] incr daytog } if {$hhcore == "HR_AVG"} { set cur_hr_avg [lindex $panoramix 2] incr hourtog } } if {$monthtog > 12} {set monthtog 1} else {set monthtog 0} if {$daytog > 30} {set daytog 1} else {set daytog 0} if {$hourtog > 24} {set hourtog 1} else {set hourtog 0} close $jericho ##################################################################### ##################################################################### #thats the actual core of the stats script # TODO: # install in the code, the peak script, so the stats suite, will also include # this feature # some kind html guru, make a descent script, to convert the stats file data, # to a kewl home page # Remove the Highest day average feature, cause it busts my balls + is useless proc stats_chk {} { global st_file curavg min_cnt summoner closeday set current_stat [llength [chanlist [channels]]] incr summoner $current_stat incr min_cnt set curavg [expr $summoner / $min_cnt] set getutime [unixtime] set wra [ctime $getutime] set getwra [lindex $wra 3] set getmins [string range $getwra 3 4] set gethour [string range $getwra 0 4] set getmonth [lindex $wra 2] if { $getmins == 00 } { log_hour_avg } if { $gethour == $closeday } { log_day_avg "0" } if { $getmonth == 1 && $gethour == "00:00"} { log_month_avg } unset getutime wra getwra getmins gethour getmonth stats_ready timer 1 stats_chk } proc refresh_logs { what } { global st_file set cnter 0 set nancy [open $st_file r] set kintaro [open "${st_file}~tmp" w] while {![eof $nancy]} { set hermes [gets $nancy] if {[eof $nancy]} {break} set hsoc [lindex $hermes 0] if {$hsoc == "$what"} { if { $cnter != 0} { puts $kintaro $hermes incr cnter } else {incr cnter} } else {puts $kintaro $hermes } } close $nancy close $kintaro exec /bin/mv "${st_file}~tmp" $st_file } proc refresh_togs {whitch1 whatflag} { global st_file set drumm [open $st_file r] set n_base [open "${st_file}~tmp" w] while {![eof $drumm]} { set junglistic [gets $drumm] if {[eof $drumm]} {break} set baseline [lindex $junglistic 0] if {$baseline != [string toupper $whitch1] } { puts $n_base $junglistic } } puts $n_base "[string toupper $whitch1] $whatflag" close $n_base close $drumm exec /bin/mv ${st_file}~tmp $st_file } proc log_hour_avg {} { global summoner st_file curavg cur_hr_avg min_cnt hourtog hrkicks hrjoins set anti [open $st_file a] set timee [unixtime] set mpee [lindex [ctime $timee] 3] lappend mpeee [string index $mpee 0][string index $mpee 1] puts $anti "HR_AVG $mpeee $curavg [unixtime] $hrkicks $hrjoins" close $anti set summoner 0 set min_cnt 0 putlog "HOUR $mpeee Closed with an average of $curavg users, $hrkicks kicks and $hrjoins joins" set hrjoins 0 set hrkicks 0 set cur_hr_avg $curavg if {$hourtog == "1"} {refresh_logs HR_AVG} else { set hourcnt 0 set zanita [open $st_file r] while {![eof $zanita]} { set pickaboo [gets $zanita] if {$pickaboo == [eof $zanita] } {break} set drum [lindex $pickaboo 0] if { $drum == "HR_AVG" } { incr hourcnt } } close $zanita if {$hourcnt > 24} { refresh_logs HR_AVG set hourtog 1 } unset hourcnt } } proc log_day_avg {shouldilog} { global st_file cur_day_avg set mpliax 0 set daysum 0 set evad [open $st_file r] while {![eof $evad]} { set zano [gets $evad] if {[eof $evad]} {break} set katsika [lindex $zano 0] if {$katsika == "HR_AVG" } { incr daysum [lindex $zano 2] incr mpliax } } close $evad set cur_day_avg [expr $daysum / $mpliax] if { $shouldilog == 0 } {put_day_log} } proc put_day_log {} { global st_file cur_day_avg curavg highest_hr_avg daytog daykicks dayjoins set gastone [open $st_file a] set heaven [unixtime] set hellfire [ctime $heaven] puts $gastone "DAY_AVG $cur_day_avg [lindex $hellfire 0] [lindex $hellfire 2] [lindex $hellfire 1] $daykicks $dayjoins" close $gastone putlog "Stats day closed, with an average of $cur_day_avg users, $daykicks kicks and $dayjoins joins" set daykicks 0 set dayjoins 0 set highest_hr_avg $curavg # check if entry's limits have been exceeded... if {$daytog == "1"} {refresh_logs DAY_AVG} else { set daycnt 0 set zanita [open $st_file r] while {![eof $zanita]} { set pickaboo [gets $zanita] if {$pickaboo == [eof $zanita] } {break} set drum [lindex $pickaboo 0] if { $drum == "DAY_AVG" } { incr daycnt } } close $zanita if {$daycnt > 30} { refresh_logs DAY_AVG set daytog 1 } unset daycnt } refresh_togs highest $curavg } proc log_month_avg {} { global st_file cur_month_avg monthtog set xaxat 0 set monthsum 0 set kalamaki [open $st_file r] while {![eof $kalamaki]} { set kat [gets $kalamaki] if {[eof $kalamaki]} {break} set katsika [lindex $kat 0] if {$katsika == "DAY_AVG" } { incr monthsum [lindex $kat 1] incr xaxat } } close $kalamaki set cur_day_avg [expr $monthsum / $xaxat] set gastone [open $st_file a] puts $gastone "MONTH_AVG $cur_month_avg [lindex [ctime unixtime] 1] [lindex [ctime unixtime] 4]" close $gastone putlog "Stats Month closed, with an average of $cur_month_avg users" if {$monthtog == 1} {refresh_logs MONTH_AVG} unset monthsum xaxat } proc stats_ready {} { global curavg st_file highest_hr_avg set ok 0 set baldrick [open $st_file r] while {![eof $baldrick]} { set biris [gets $baldrick] if {[eof $baldrick]} {break} set borjo [lindex $biris 0] if {$borjo == "HIGHEST"} { if {[lindex $biris 1] < $curavg} { putlog "*** New Highest Daily User average: $curavg" set ok 1 set highest_hr_avg $curavg } } } close $baldrick #if current average iz higher than the highest one, replace the old entry if {$ok == 1} { refresh_togs highest $curavg set ok 0 } } stats_chk #compiled by BaBBoS #Email bugs/questions/suggestions at babbos@delta.edu.gr StatsSuite/kicklog.tcl100644 766 144 6744 6156175656 14207 0ustar babbosusers #Channel kick/join stats ... first char typed at 29/5/97 #Lots and lots of vars, huh :> # Note ... the hrkicks.daykicks,hrjoins and dayjoins Vars, are being loged # through the stats.core.tcl script, so you wont see any file loging # of these here... set kickers "" set counterr 0 set ttlkicks 0 set hrkicks 0 set daykicks 0 set ttljoins 0 set dayjoins 0 set hrjoins 0 set kickbuf "" set critical 0 bind kick - * kick_issue bind join - * log_join #### These Unbinds and binds where done , so that #### the script can charge the kicks to the users that actually called em #### through the bot. Autokicks, protect kicks, etc will be charged on the bot unbind dcc * kickban *dcc:kickban unbind dcc * kick *dcc:kick bind dcc o kickban kick_ban bind dcc o kick kick_proc bind dcc o kb *dcc:kickban bind dcc o kck *dcc:kick proc kick_ban {hand idx args} { if {[string length $args] > 9} { set args [string range $args 1 [expr [string length $args] - 2]] } if {[onchan [lindex $args 0] [lindex [channels] 0]]} { log_kick [string tolower $hand] 1 dccsimul $idx ".kb $args" } else { putdcc $idx "[lindex $args 0] is not on [lindex [channels] 0]" return 0 } } proc kick_proc {hand idx args} { if {[string length $args] > 9} { set args [string range $args 1 [expr [string length $args] - 2]] } if {[onchan [lindex $args 0] [lindex [channels] 0]]} { log_kick [string tolower $hand] 1 dccsimul $idx ".kck $args" } else { putdcc $idx "[lindex $args 0] is not on [lindex [channels] 0]" return 0 } } proc kick_issue {nicks userhost handle channel kicked-nick reason} { global critical nick if {$critical == 1 && $handle == $nick } { set critical 0 return 0 } if {$handle == "*"} { set handle [string tolower $nicks] } log_kick [string tolower $handle] 0 } proc log_kick {handle wherefrom} { global ttlkicks daykicks hrkicks kickers kickbuf nick critical if {$wherefrom == 1} {set critical 1} set kickback "" set exists 0 incr ttlkicks incr daykicks incr hrkicks foreach j $kickbuf { if {[lindex $j 1] != $handle} { lappend kickback $j } else { lappend kickback "KICKERS $handle [expr [lindex $j 2] + 1]" set exists 1 } } if {$exists != 1} {lappend kickback "KICKERS $handle 1"} set kickbuf $kickback unset kickback } proc log_join {nick uhost handle chan} { global ttljoins dayjoins hrjoins counterr incr ttljoins incr dayjoins incr hrjoins incr counterr if {$counterr > 10} { update_file update_vars } } proc update_file {} { global kick_file kickers kickbuf ttlkicks ttljoins counterr set krisi [open $kick_file w] foreach j $kickbuf { puts $krisi $j } puts $krisi "KICKS $ttlkicks" puts $krisi "JOINS $ttljoins" close $krisi set counterr 0 set kickbuf "" } proc update_vars {} { global kick_file kickbuf ttlkicks ttljoins set ndk [open $kick_file r] while {![eof $ndk]} { set killed [gets $ndk] if {[eof $ndk]} {break} if {[lindex $killed 0] == "KICKERS"} { lappend kickbuf $killed } if {[lindex $killed 0] == "KICKS"} {set ttlkicks [lindex $killed 1]} if {[lindex $killed 0] == "JOINS"} {set ttljoins [lindex $killed 1]} } close $ndk } if {[file exists $kick_file]} {update_vars} #Compiled by BaBBoS StatsSuite/stats.binds.tcl100644 766 144 25753 6156172116 15025 0ustar babbosusers# Internal dcc commands, for viewing the stats in an eatchy nicy way... # This file can be totaly changed, and is not needed, for the other # two scripts (stats.core.tcl, kicklog.tcl) to run. bind dcc p stats stats_bind bind dcc p kicks kicks_bind proc stats_bind {hand idx arg} { global curavg cur_hr_avg avgdaycount cur_day_avg highest_hr_avg st_file ttlkicks ttljoins set optionz [lindex $arg 0] set tellme [string tolower $optionz] if { $tellme == "help" } { putdcc $idx "Usage: stats