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.

How to get user list on specified channel?

Help for those learning Tcl or writing their own scripts.
Post Reply
D
DzieX
Voice
Posts: 6
Joined: Tue Jun 19, 2007 7:58 am

How to get user list on specified channel?

Post by DzieX »

I tried to use command: chanlist <channel> [flags[&chanflags]], but documentation says:
documentation wrote:Returns: list of nicknames currently on the bot's channel that have all of the flags specified;. If no flags are given, all of the nicknames are returned. Please note that if you're executing chanlist after a part or sign bind, the gone user will still be listed, so you can check for wasop, isop, etc.
I don't know how to get list of users which are currently on my channel :(
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

.channel #channel
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

What's meant by the comment you highlighted is that if you execute this command in a sign/part procedure, the nick which parted/signed will still be listed in the chan list. If you're not executing it inside a sign/part-proc then you'll be getting the list of users currently in the channel. However, if it is being used inside a part/sign-proc you can simply exclude the nick that parted from the chanlist.
D
DzieX
Voice
Posts: 6
Joined: Tue Jun 19, 2007 7:58 am

Post by DzieX »

I thought, I can do it simpler, but OK.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

DzieX wrote:I thought, I can do it simpler, but OK.
It is simple. What exactly is your problem?
D
DzieX
Voice
Posts: 6
Joined: Tue Jun 19, 2007 7:58 am

Post by DzieX »

All events call the same function with one parameter - channel name, so I don't have access to nick and can't exclude it from list.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

doc/tcl-commands.doc wrote: (9) PART (stackable)
bind part <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <msg>

Description: triggered by someone leaving the channel. The mask is
matched against "#channel nick!user@host" and can contain
wildcards. If no part message is specified, msg will be set
to "".

New Tcl procs should be declared as
proc partproc {nick uhost hand chan {msg ""}} { ... }
for compatibility.
Module: irc

(10) SIGN (stackable)
bind sign <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <reason>

Description: triggered by a signoff, or possibly by someone who got
netsplit and never returned. The signoff message is the last
argument to the proc. Wildcards can be used in the mask, which is
matched against '#channel nick!user@host'.
Module: irc
You've got nick, ident@host, possible handle, channel, and for sign, reason. Obviously, both these will provide the nickname of the one who left, and thus excluding it from the output of chanlist should'nt be so hard using a few temporary variables, lreplace, and lsearch.
DzieX wrote:All events call the same function with one parameter - channel name, so I don't have access to nick and can't exclude it from list.
What are you talking about here? The only two bindings that are effected are the PART and SIGN bindings, both which supply alot more than simply a channelname...
NML_375
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

DzieX wrote:All events call the same function with one parameter - channel name, so I don't have access to nick and can't exclude it from list.
Ok, then as I said before you are getting the nicks that are currently in the channel and you need no "nick" to be removed.

Unless you're using it inside PART or SIGN binds, you don't need to remove the parting/quitting nick from the chanlist list.
D
DzieX
Voice
Posts: 6
Joined: Tue Jun 19, 2007 7:58 am

Post by DzieX »

Ok, maybe if I paste script in here You will understand what I'm writing about:

Code: Select all

proc join {nick host handle chan} {
    make $chan
}
proc kick {nick host handle chan knick arg} {
    make $chan
}
proc mode {nick host handle chan arg mnick} {
    make $chan
}
proc nick {nick host handle chan newnick} {
    make $chan
}
proc part {nick host handle chan rest} {
    make $chan
}
proc sign {nick host handle chan arg} {
    make $chan
}
proc topc {nick host handle chan topic} {
    make $chan
}

Code: Select all

bind join - * join
bind kick - * kick
bind mode - * mode
bind nick - * nick
bind part - * part
bind sign - * sign
bind topc - * topc
make is my procedure, which writes all data to database (6 records :P).

OK, now I know how to do that. make will get one extra default parameter - nickname. In procedures sign and part, it will get user name, who has left channel. In other no (parameter by default will be "").

Thanks, for help and patience :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Ok, so

Code: Select all

proc make {chan {nick ""}} {
 set chanlist [chanlist $chan]
 if {$nick != ""} {
  set i [lsearch -exact $chanlist $chan]
  set chanlist [lreplace $chanlist $i $i]
 }
 # do whatever here
}
So, in you part/sign/kick procedures, pass an extra argument to [make] which is $nick.
Post Reply