This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Listing All Users & Counting Ops

Old posts that have not been replied to for several years.
Locked
L
Longbow
Voice
Posts: 29
Joined: Thu Jan 13, 2005 9:24 am

Listing All Users & Counting Ops

Post by Longbow »

Code: Select all

puts $thewritefile "[chanlist $chan]"
Ok that writes all the current users in the channel to $mywritefile, there are 2 problems though..

1. For people using [ ] in there name, it will output { } around there name..

Example..
[Clan]Name
Turns to..
{[Clan]Name}
2. How would I go about putting a comma after each name.

Now for counting Ops i'm guessing it's going to use the 3 bits of code below, but I don't know how I would do it.

Code: Select all

if {[isop $nick $chan]}

[llength [chanlist #clantemplates]]

foreach nick [chanlist $chan]
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

This should take care of both problems

Code: Select all

puts $thewritefile "[join [chanlist $chan] {, }]"
L
Longbow
Voice
Posts: 29
Joined: Thu Jan 13, 2005 9:24 am

Post by Longbow »

Mmmm.... indeed that does, but whats the join there for?

Does that mean I don't need the bind join / proc?
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

No, join only put together several list elements into a single string.
L
Longbow
Voice
Posts: 29
Joined: Thu Jan 13, 2005 9:24 am

Post by Longbow »

What would I use for for the same script but binded with sign and part?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

in your proc, replace:

Code: Select all

puts $thewritefile "[chanlist $chan]"
with

Code: Select all

puts $thewritefile "[join [chanlist $chan] {, }]"
L
Longbow
Voice
Posts: 29
Joined: Thu Jan 13, 2005 9:24 am

Post by Longbow »

Yeah I already done that, I was asking can I just use that for sign/part procs/binds aswell..
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Longbow wrote:Yeah I already done that, I was asking can I just use that for sign/part procs/binds aswell..
Try it, do you see any reason not to ?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

For counting the ops you can simply use:

Code: Select all

set count 0
foreach user [chanlist $chan] {
 if {[isop $user $chan]} {
  incr count
  }
}
putserv "PRIVMSG $chan :Total number of ops: $count"
You can do the same for voices and etc.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
L
Longbow
Voice
Posts: 29
Joined: Thu Jan 13, 2005 9:24 am

Post by Longbow »

Thanks.

Ok, this is my whole script..

Code: Select all

########## Total/Op/Voice/Users ##########
bind join - * join:all
proc join:all {nick uhost hand chan} {
set mychan "#longbow"
set wtotal [open total.php w]
set wop [open op.php w]
set wvoice [open voice.php w]
set wusers [open users.php w]

puts $wtotal "[llength [chanlist $mychan]]"

set opcount 0
foreach user [chanlist $mychan] {
 if {[isop $user $mychan]} {
  incr opcount
  }
}
puts $wop "$opcount"

set voicecount 0
foreach user [chanlist $mychan] {
 if {[isvoice $user $mychan]} {
  incr voicecount
  }
}
puts $wvoice "$voicecount"

puts $wusers "[join [chanlist $mychan] {, }]"

close $mychan
close $wtotal
close $wop
close $wvoice
close $wusers

}

########## Most Users ##########
bind join - * join:most
proc join:most {nick uhost hand chan} {
set mychan "#longbow"
set rmost [open most.php r]
set wmost [open most.php w]
set wmostdate [open mostdate.php w]

gets $rmost line

if {[llength [chanlist $mychan]] > $line} { 
set systemTime [clock seconds]
puts $wmost "[llength [chanlist $mychan]]"
puts $wmostdate "[clock format $systemTime -format {%b %d %Y}]"
}

close $mychan
close $rmost
close $wmost
close $wmostdate
close $line

}
But I get the following error:
Tcl error [join:all]: can not find channel named "#longbow"
Tcl error [join:most]: can not find channel named "#longbow"
L
Longbow
Voice
Posts: 29
Joined: Thu Jan 13, 2005 9:24 am

Post by Longbow »

Ah woops, I found what was wrong.

Still getting loads of problems though...

Code: Select all

########## Join - Total/Op/Voice/Users ##########
bind join - * join:all
proc join:all {nick uhost hand chan} {
set mychan #longbow
set wtotal [open total.php w]
set wop [open op.php w]
set wvoice [open voice.php w]
set wusers [open users.php w]

puts $wtotal "[llength [chanlist $mychan]]"

set opcount 0
foreach user [chanlist $mychan] {
 if {[isop $user $mychan]} {
  incr opcount
  }
}
puts $wop "$opcount"

set voicecount 0
foreach user [chanlist $mychan] {
 if {[isvoice $user $mychan]} {
  incr voicecount
  }
}
puts $wvoice "$voicecount"

puts $wusers "[join [chanlist $mychan] {, }]"

close $wtotal
close $wop
close $wvoice
close $wusers

}

########## Part - Total/Op/Voice/Users ##########
bind sign - * part:all
proc part:all {nick uhost hand chan msg} {
set mychan #longbow
set wtotal [open total.php w]
set wop [open op.php w]
set wvoice [open voice.php w]
set wusers [open users.php w]

puts $wtotal "[llength [chanlist $mychan]]"

set opcount 0
foreach user [chanlist $mychan] {
 if {[isop $user $mychan]} {
  incr opcount
  }
}
puts $wop "$opcount"

set voicecount 0
foreach user [chanlist $mychan] {
 if {[isvoice $user $mychan]} {
  incr voicecount
  }
}
puts $wvoice "$voicecount"

puts $wusers "[join [chanlist $mychan] {, }]"

close $wtotal
close $wop
close $wvoice
close $wusers

}

########## Sign - Total/Op/Voice/Users ##########
bind sign - * sign:all
proc sign:all {nick uhost hand chan reason} {
set mychan #longbow
set wtotal [open total.php w]
set wop [open op.php w]
set wvoice [open voice.php w]
set wusers [open users.php w]

puts $wtotal "[llength [chanlist $mychan]]"

set opcount 0
foreach user [chanlist $mychan] {
 if {[isop $user $mychan]} {
  incr opcount
  }
}
puts $wop "$opcount"

set voicecount 0
foreach user [chanlist $mychan] {
 if {[isvoice $user $mychan]} {
  incr voicecount
  }
}
puts $wvoice "$voicecount"

puts $wusers "[join [chanlist $mychan] {, }]"

close $wtotal
close $wop
close $wvoice
close $wusers

}

########## Most Users ##########
bind join - * join:most
proc join:most {nick uhost hand chan} {
set mychan #longbow
set rmost [open most.php r]
set wmost [open most.php w]
set wmostdate [open mostdate.php w]

gets $rmost line

if {[llength [chanlist $mychan]] > $line} { 
set systemTime [clock seconds]
puts $wmost "[llength [chanlist $mychan]]"
puts $wmostdate "[clock format $systemTime -format {%b %d %Y}]"
}

close $rmost
close $wmost
close $wmostdate

}
Most Users doesn't work, it seems to work the same as current users. So when the channel users goes down, so does most users. :x

Also the part/sign bit isn't working.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Try opening one file at a time, save your value in it, close it and then go for the next one.

Plus I don't understand why don't you save them in an array rather than writing all different files? Or just write all vaues into one file. Surely it will cut down your long code and will make the bot more efficient and probobaly more faster in replying.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
L
Longbow
Voice
Posts: 29
Joined: Thu Jan 13, 2005 9:24 am

Post by Longbow »

Ah, I got it all sorted, thanks. :)
Locked