I created the following file (with some stolen code). The purpose is to count the number of users in a channel and write that to a file.
It does update the number of people in chat when they join nicely, but not when someone leaves the channel. Could someone comment on it as I'm very poor at TCL.
Code: Select all
set cc_outptpath "/home/doos/"
set cc_outptfile "whoisonline.txt"
# $cc_chanlist
# List of channels to monitor (ommit #)
set cc_chanlist {go}
bind join - * cc_join
bind part - * cc_part
bind sign - * cc_sign
bind kick - * cc_kick
bind splt - * cc_split
proc cc_countusers {chan} {
global cc_outptfile cc_outptpath
set totalusers [llength [chanlist #go]]
set c [catch {set fd [open "$cc_outptpath$chan.$cc_outptfile" w]} reason]
puts $fd $totalusers
catch {close $fd}
return 0
}
proc cc_join {nick uhost handle chan} {
regsub -all "\#" $chan "" chan
global cc_chanlist
if {[lsearch $cc_chanlist $chan] != -1} {cc_countusers $chan}
#puthelp "PRIVMSG #go :Doos is an idiot."
return 0
}
proc cc_part {nick uhost handle chan msg} {
regsub -all "\#" $chan "" chan
global cc_chanlist
if {[lsearch $cc_chanlist $chan] != -1} {cc_countusers $chan}
return 0
}
proc cc_sign {nick uhost handle chan msg} {
regsub -all "\#" $chan "" chan
global cc_chanlist
if {[lsearch $cc_chanlist $chan] != -1} {cc_countusers $chan}
return 0
}
proc cc_kick {nick uhost handle chan msg} {
regsub -all "\#" $chan "" chan
global cc_chanlist
if {[lsearch $cc_chanlist $chan] != -1} {cc_countusers $chan}
return 0
}
proc cc_split {nick uhost handle chan msg} {
regsub -all "\#" $chan "" chan
global cc_chanlist
if {[lsearch $cc_chanlist $chan] != -1} {cc_countusers $chan}
return 0
}
# Check for a QUIT
proc hung_up {nick uhost handle chan msg} {
regsub -all "\#" $chan "" chan
global cc_chanlist
if {[lsearch $cc_chanlist $chan] != -1} {cc_countusers $chan}
return 0
}
putlog "\002WHOSONLINE:\002 countlist.tcl Version1 is loaded."