egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Logging number of users to file

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Doos
Voice


Joined: 07 Jul 2005
Posts: 9

PostPosted: Tue May 16, 2006 11:31 am    Post subject: Logging number of users to file Reply with quote

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
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Tue May 16, 2006 4:11 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber