| View previous topic :: View next topic |
| Author |
Message |
Doos Voice
Joined: 07 Jul 2005 Posts: 9
|
Posted: Tue May 16, 2006 11:31 am Post subject: Logging number of users to file |
|
|
Hi all,
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: | 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."
|
Thanks in advance. |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Tue May 16, 2006 4:11 pm Post subject: |
|
|
This is because when part is triggered, the user is still on the channel. just give your proc a hint if it was a part and then expr -1 the totalusers. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
|