### CHANNELTALK STATISTICS ### By Goblet 1997 email: goblet@sci.fi ### ### Sorry for some finnish-language variable names, ### I'm just too lazy to translate them... ### ---------------------------------------------------------------- ### Masters can zero somebody's stats with command .formuser handle ### and users can also ask their stats ny msging the bot word "STAT" catch {unset wwwfile} catch {unset wwwlfile} catch {unset lfile} ## These are in order: ## fastlog file for logging the channel which clears after 200 publics ## webfile with a html-table ## webfile, only text for lynx users. ##which channel should stat? set statchan "#ste31" set lfile "/wwwhome/goblet/public_html/ste31/ste31.log.fast" logfile jkps * $lfile set wwwfile "/wwwhome/goblet/public_html/ste31/ste31stat.htm" set wwwlfile "/wwwhome/goblet/public_html/ste31/ste31stat_lynx.htm" ## after how many publics should update be done? set updatestat 10 ## should userfile be saved same time as the statistics-web page updates? set saveonupdate 1 ### ------ code begins ----------------------- bind pubm - * count_words proc count_words {nick uhost hand chan text} { if {[validuser $hand] != 1} {return 0} set sana 1 set kirjain 0 foreach i [split $text {}] { incr kirjain if {$i == " "} { incr sana } } set sanoja [user_get $hand "words"] user_set $hand "words" [expr { $sanoja + $sana }] set pubcomments [user_get $hand "comments"] user_set $hand "comments" [expr { $pubcomments + 1 }] set kirj [user_get $hand "letters"] user_set $hand "letters" [expr { $kirj + $kirjain - $sana + 1 }] } ## .formuser handle clears somebody's statistics if he has flooded ## to get higher on list (this has really happened ;-) bind dcc m formuser dcc_formatuser proc dcc_formatuser {hand idx text} { putlog "Set parms user $text to 0" user_set $text "words" 0 user_set $text "comments" 0 user_set $text "letters" 0 user_set $text "gone" 0 } proc user_get {handle key} { set xtra [getxtra $handle] for {set i 0} {$i < [llength $xtra]} {incr i} { set this [lindex $xtra $i] if {[string compare [lindex $this 0] $key] == 0} { return [lindex $this 1] } } return 0 } proc user_set {handle key data} { set xtra [getxtra $handle] for {set i 0} {$i < [llength $xtra]} {incr i} { set this [lindex $xtra $i] if {[string compare [lindex $this 0] $key] == 0} { set this [list $key $data] setxtra $handle [lreplace $xtra $i $i $this] return } } lappend xtra [list $key $data] setxtra $handle $xtra } ## word/comment/lettercounter ends set cmnts [expr { $updatestat -1 }] set cmnts2 198 bind pubm - * count_comment proc count_comment {nick uhost hand chan text} { global cmnts cmnts2 lfile incr cmnts incr cmnts2 if {$cmnts >= $updatestat} { set cmnts 0 if {$saveonupdate == 1} {save} do_stats } if {$cmnts2 >= 200} { set fdlog [open $lfile w] set cmnts2 1 puts $fdlog "log start [date] [time]" close $fdlog } } proc do_stats {} { global wwwfile wwwlfile set fd [open $wwwfile w] set fdl [open $wwwlfile w] puts $fd "" puts $fd "
Nr" puts $fd " | Nick" puts $fd " | Hostmask" puts $fd " | Last on" puts $fd " | Words" puts $fd " | Comments" puts $fd " | Letters" foreach i [userlist] { if {[matchattr $i 1] == 0} { set apu "[user_get $i "words"] $i" lappend apulist $apu } } set apulista [lsort -decreasing -command cmp $apulist] set no 0 foreach i $apulista { incr no if {$no < 51} { puts $fd " |
---|---|---|---|---|---|---|
$no | " puts $fd "$handle | " puts $fd "$chost | " puts $fd "$lastonchan | " puts $fd "$w_word | " puts $fd "$w_comm | " puts $fd "$w_letr | " puts $fdl "