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.

user count in channel

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

user count in channel

Post by T-Xorcist »

Hi,

Can someone please help with an script?

I need a script which counts the people in a channel. It is for a bot.
If the bot is the only one in the channel, it parts the channel.
I guess it needs to be putted in the bind part.

Can someone write something for me?

I allready found something with users:

Code: Select all

foreach user $nicklist {
    if {([isop $user $channel])} {
    	lappend oplist $user
       } elseif {([isvoice $user $channel])} {
    	lappend voicelist $user
    	} else {
   	 lappend userlist $user
   }
}
This is for mass opping the users in the channel.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

[llength [chanlist <channel>]]
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

bind time  - ?0* checkc

proc checkc args {
 if {[llength [chanlist #yourchannel]] == 1} {
  channel remove #yourchannel
 }
}
this checks every 10 minutes, if #yourchannel is empty the bot parts it.
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Post by T-Xorcist »

Well, I was thing more like this:

Code: Select all

bind raw - PART proc:part

proc proc:part {nick uhost hand chan} {
 if {[llength [chanlist $chan]] == 1} {
    putquick "PRIVMSG #Bots :Leaving \002$chan\002 - Reason: \002Empty channel!\002"
  }
}
But this doesn't work.
bind raw - PART proc:part doesn't seem to work.
bind part - * proc:part doesn't seem to work either.

How do I trigger something when someone parts the channel?
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

bind part takes 5 arguments not 4 (reason included)

Code: Select all

bind part - * proc:part

proc proc:part {nick uhost hand chan rsn} {
 if {[llength [chanlist $chan]] == 1} {
  putquick "privmsg #bots :$chan is empty, parting it now!"
 }
}
PS: raw takes 3 arguments.
RAW (stackable)
bind raw <flags> <keyword> <proc>
procname <from> <keyword> <text>

Description: previous versions of Eggdrop required a special compile
option to enable this binding, but it's now standard. The keyword
is either a numeric, like "368", or a keyword, such as "PRIVMSG".
from will be the server name or the source user (depending on
the keyword); flags are ignored. The order of the arguments is
identical to the order that the IRC server sends to the bot. The
pre-processing only splits it apart enough to determine the
keyword. If the proc returns 1, Eggdrop will not process the line
any further (this could cause unexpected behavior in some cases).
Module: server
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Post by T-Xorcist »

I get the following error in the logfile:

Tcl error [proc:part]: invalid channel: #bots

Why? the channel excists :roll:
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Is #bots the channel the bot is parting? If so, once the bot removes it, it becomes invalid.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

A 'if {![validchan $chan]} return' should fix this.
Once the game is over, the king and the pawn go back in the same box.
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Post by T-Xorcist »

Sir_Fz wrote:Is #bots the channel the bot is parting? If so, once the bot removes it, it becomes invalid.
No, the bot is allways in #bots. He must say that he is leaving a channel in #bots.
But it still doesn't work :(

And your solution doesn't work either ceasar :cry:
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Try removing the channel and adding it again.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

it sounds like you have 2 binds to the chan, one that messages and the other removes the channel before the is called, that would be one of the possible reasons I can think of for that error.
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...
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Post your script T-Xorcist so that we can see where the problem is.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Post by T-Xorcist »

Yes, here it comes again. This is what I have right now.

Code: Select all

bind part - * proc:part

proc proc:part {nick uhost hand chan rsn} {
  if {[validchan $chan]} {
    if {[llength [chanlist $chan]] == 1} {
      putquick "PRIVMSG #bots :\002$chan\002 is empty, parting it now!"
      channel remove $chan
    }
  }
}
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

The part proc also gets called when your bot parts. Try

Code: Select all

bind part - * proc:part

proc proc:part {nick uhost hand chan rsn} {
  if {[isbotnick $nick]} {return 0}
  if {[llength [chanlist $chan]] == 1} {
    if {[validchan #bots]} {
      putquick "PRIVMSG #bots :\002$chan\002 is empty, parting it now!"
    }
    channel remove $chan
  }
}
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Post by T-Xorcist »

This is what I tried so far.

Code: Select all

proc proc:part {nick uhost hand chan rsn} {
  putquick "PRIVMSG $nick :You just parted \002$chan\002"
}
The code above works!

Code: Select all

proc proc:part {nick uhost hand chan rsn} {
  channel remove $chan
}
The code above works!

Code: Select all

proc proc:part {nick uhost hand chan rsn} {
  putquick "PRIVMSG $nick :[llength [chanlist $chan]]"
}
With the code above, I located the problem!
When I parted, and the bot was alone, I got the number 2
So if the last man parted, it is 2, not 1!

Now it works perfect and he displays it in #bots!

Thanks for all your effort to help me out because it sure helped me!!

Respect, T-Xorcist
Post Reply