mIRC Home    About    Download    Register    News    Help

Topic Options
#265056 - 22/02/19 10:20 AM How to know the total users of a chan in a join
dukealex Offline
Bowl of petunias

Registered: 18/02/19
Posts: 2

I want to know is a possibility to obtain the total number of users of a chan directly ON JOIN event (when i join a channel) without using a timer, i.e. before the nicklist is initiated on that channel.

For example:

ON 1:JOIN:#: {
  if ($nick == $me) echo -a $nick(#,0)

In this way, it will echo $nick(#,0) -> 1, because the ON JOIN event process the commands before all the nicks is initiated. Of course, i can use /timer 1 0 echo -a $nick(#,0), but i need to know the total users before calling the NickLust (Custom DLL of Nicklist), because Nicklust can be initiated only ON JOIN event without using a delay or a timer.

Edited by dukealex (22/02/19 10:21 AM)

#265059 - 22/02/19 02:16 PM Re: How to know the total users of a chan in a join [Re: dukealex]
Dazuz Offline
Vogon poet

Registered: 01/12/15
Posts: 116
Loc: Finland
You can only know the total number of users on a channel when you receive RAW 366, you can start checking for number of users when you receive RAW 353, but if it's a large channel, the server can send you multiple RAW 353s.

raw 353:*:echo -t $3 * $nick($3,0) users counted on $3 so far!

raw 366:*:echo -t $2 * Total of $nick($2,0) users on $2 $+ !

In other words: you can't know the number of users on the channel on join. Only after you receive the names.

#265084 - 28/02/19 05:20 PM Re: How to know the total users of a chan in a join [Re: dukealex]
Erasimus Offline
Babel fish

Registered: 26/04/18
Posts: 72
I agree with Dazuz. At the point of your On Join there is no information to give you. There are zero users in the nicklist.

Instead the nicklist is populated by the server when it sends you the list of users in the raw numeric 353 message(s), and concludes with the raw 366 message (End of list for channel #<channel name>'.

I found this out by checking for the presence of a user (Idlebot in an IdleRPG game) when I joined. It wasn't there, but it was a few miliseconds later, so I switched to process on the raw 366 - no timer needed.

There is a problem if you try to count the users while the raw 353 messages are arriving. There are 2 different ways the nicks are presented.

Normally the are sent as nick!e-mailname@hostaddress. IF usermode +x has been applied then you just get a list of nicks.

Personally I would wait and trap the raw 366 and then do your $user thing.

raw 366:*: { echo -a User Count : $nick(#,0) }

You can check if the end of list is for your channel by
raw 366:*: { 
   if $2 == #channelname { echo -a User Count : $nick(#,0) }

2 things to note:
1) this is already done for you anyway, just look at the window bar for the channel - the user count is there in brackets just after the channel name.

2) your on join could have been compressed into
ON ME:1:JOIN:#: {

which means that you no longer have to test if the nick joining == $me

Hope this helps.

Edited by Erasimus (28/02/19 05:24 PM)