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 

user count in channel
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Fri Jan 06, 2006 2:34 pm    Post subject: user count in channel Reply with quote

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
View user's profile Send private message Visit poster's website
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Fri Jan 06, 2006 5:02 pm    Post subject: Reply with quote

Code:
[llength [chanlist <channel>]]
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Jan 06, 2006 7:42 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Fri Jan 06, 2006 8:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Jan 06, 2006 8:39 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Fri Jan 06, 2006 8:49 pm    Post subject: Reply with quote

I get the following error in the logfile:

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

Why? the channel excists Rolling Eyes
_________________
is-1337.org IRC server!
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Jan 07, 2006 10:52 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Sat Jan 07, 2006 4:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Sat Jan 07, 2006 9:45 pm    Post subject: Reply with quote

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 Sad

And your solution doesn't work either ceasar Crying or Very sad
_________________
is-1337.org IRC server!
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Jan 07, 2006 11:45 pm    Post subject: Reply with quote

Try removing the channel and adding it again.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Jan 08, 2006 9:23 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Sun Jan 08, 2006 10:10 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Sun Jan 08, 2006 10:14 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun Jan 08, 2006 10:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Sun Jan 08, 2006 5:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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