| View previous topic :: View next topic |
| Author |
Message |
T-Xorcist Halfop
Joined: 14 Nov 2005 Posts: 47 Location: Netherlands
|
Posted: Fri Jan 06, 2006 2:34 pm Post subject: user count in channel |
|
|
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: | 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. _________________ is-1337.org IRC server! |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Fri Jan 06, 2006 5:02 pm Post subject: |
|
|
| Code: | | [llength [chanlist <channel>]] |
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Jan 06, 2006 7:42 pm Post subject: |
|
|
| Code: | 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. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
T-Xorcist Halfop
Joined: 14 Nov 2005 Posts: 47 Location: Netherlands
|
Posted: Fri Jan 06, 2006 8:31 pm Post subject: |
|
|
Well, I was thing more like this:
| Code: | 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? _________________ is-1337.org IRC server! |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Jan 06, 2006 8:39 pm Post subject: |
|
|
bind part takes 5 arguments not 4 (reason included)
| Code: | 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.
| Quote: | 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
|
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
T-Xorcist Halfop
Joined: 14 Nov 2005 Posts: 47 Location: Netherlands
|
Posted: Fri Jan 06, 2006 8:49 pm Post subject: |
|
|
I get the following error in the logfile:
Tcl error [proc:part]: invalid channel: #bots
Why? the channel excists  _________________ is-1337.org IRC server! |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Jan 07, 2006 10:52 am Post subject: |
|
|
Is #bots the channel the bot is parting? If so, once the bot removes it, it becomes invalid. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Jan 07, 2006 4:17 pm Post subject: |
|
|
A 'if {![validchan $chan]} return' should fix this. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
T-Xorcist Halfop
Joined: 14 Nov 2005 Posts: 47 Location: Netherlands
|
Posted: Sat Jan 07, 2006 9:45 pm Post subject: |
|
|
| 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  _________________ is-1337.org IRC server! |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun Jan 08, 2006 9:23 am Post subject: |
|
|
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... |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Sun Jan 08, 2006 10:10 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
T-Xorcist Halfop
Joined: 14 Nov 2005 Posts: 47 Location: Netherlands
|
Posted: Sun Jan 08, 2006 10:14 am Post subject: |
|
|
Yes, here it comes again. This is what I have right now.
| Code: | 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
}
}
} |
_________________ is-1337.org IRC server! |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Jan 08, 2006 10:42 am Post subject: |
|
|
The part proc also gets called when your bot parts. Try
| Code: | 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
}
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
T-Xorcist Halfop
Joined: 14 Nov 2005 Posts: 47 Location: Netherlands
|
Posted: Sun Jan 08, 2006 5:31 pm Post subject: |
|
|
This is what I tried so far.
| Code: | proc proc:part {nick uhost hand chan rsn} {
putquick "PRIVMSG $nick :You just parted \002$chan\002"
} |
The code above works!
| Code: | proc proc:part {nick uhost hand chan rsn} {
channel remove $chan
} |
The code above works!
| Code: | 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 _________________ is-1337.org IRC server! |
|
| Back to top |
|
 |
|