mIRC Home    About    Download    Register    News    Help

Topic Options
#241340 - 10/04/13 07:50 AM get a list of everyone in the chan into a txt file
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
I have been looking for a code that puts every person currently in a channel I'm in into a text file. I am currently adding users to a text file as they join but if I get disconnected and people join they don't get added to the file unless I manually add them.

Does anyone have any ideas? Thanks in advance.

Top
#241341 - 10/04/13 08:46 AM Re: get a list of everyone in the chan into a txt file [Re: RuLerZ]
Deega Offline
Vogon poet

Registered: 30/10/12
Posts: 164
When you re-connect & re-join the channel the names list is sent, so when you get raw 366 (End of Names list) simply loop through $nick($2,N) and use /write's -s switch.
Code:
raw 366:& #channelname *:{
  var %i = 1
  while ($nick($2,%i)) {
    write -s $+ $v1 file.txt $v1
    inc %i
  }
}

Change: #channelname to your channels name.

Top
#241342 - 10/04/13 03:59 PM Re: get a list of everyone in the chan into a txt file [Re: RuLerZ]
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
Thank you so much this works perfectly. Now when I get disconnected I have it delete the file then rejoin and it remakes the file and on join people get added and as they part/quit/kick they get removed. You are awesome!! TY so much.

Top
#241343 - 10/04/13 10:31 PM Re: get a list of everyone in the chan into a txt file [Re: RuLerZ]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
Code:
on *:disconnect: {
 if ($isfile(file.txt)){ write -c file.txt }
}

This will clear the file for you when you disconnect. Or you can use it when you connect.
Code:
on *:connect: {
 if ($isfile(file.txt)){ write -c file.txt }
}

Now you dont need to delete the file every time you disconnect from the server.
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#241344 - 10/04/13 11:06 PM Re: get a list of everyone in the chan into a txt file [Re: sparta]
Deega Offline
Vogon poet

Registered: 30/10/12
Posts: 164
Well, you can put it into the same event. Plus there is no need to check if it exists first, you're going to clear and write to it anyway wink
No need for the -s switch either, now that its cleared.
Code:
raw 366:& #channelname *:{
  write -c file.txt
  var %i = 1
  while ($nick($2,%i)) {
    write file.txt $v1
    inc %i
  }
}

Top
#244063 - 21/01/14 04:56 AM Re: get a list of everyone in the chan into a txt file [Re: Deega]
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
I have been using this code for a while now and it has been perfect but I have found that when there are 2k+ people in the channel mirc freezes on connect.

I am wondering if there was any other way to write this that would allow for much larger channels.

Any help is appreciated.

Top
#244124 - 25/01/14 04:05 AM Re: get a list of everyone in the chan into a txt file [Re: RuLerZ]
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
Here is a video example of raw 366 loop unable to handle over 14.5k users. I am wondering if there is another way rather then looping. http://www.youtube.com/watch?v=i_djV_epz-Y


Edited by RuLerZ (25/01/14 04:10 AM)

Top
#244129 - 25/01/14 02:32 PM Re: get a list of everyone in the chan into a txt file [Re: Deega]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1264
That video is private.

This may work better:

Code:
on me:*:join:#chan:{
  write -c names.txt
}

raw 353:& & #chan *:{
  write names.txt $replace($4-,$chr(32),$crlf)
}


Edited by Loki12583 (25/01/14 02:50 PM)

Top
#244145 - 26/01/14 04:46 AM Re: get a list of everyone in the chan into a txt file [Re: Loki12583]
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
Thank you so much Loki, you are awesome! Since I Add people on join and remove people on part I found the need to use ini files for performance so I altered the code to reflect using an INI:
Code:
on me:*:join:#chan:{
  remove -b inroom.ini
}

raw 353:& & #chan *:{
  writeini inroom.ini room $replace($4-,$chr(32),$chr(61) $+ $adate at $time $+ $crlf) $chr(32)
}

I am putting the date entered in the ini for each nick hence replacing spaces with =date at time to keep the ini formatted correctly, and just choose for a space to be placed at the end of the raw dump on the last nick.

This is working great I can use this code in 80k+ people with join/part writing ini scripts with little to no freezing.

The only fine tuning I need to do is the first person entered is incorrect:
lucky1223=01/26/2014=at 05:31:46
roflbaum=01/26/2014 at 05:31:46
ashrak_usedasashield=01/26/2014 at 05:31:46
jihaz=01/26/2014 at 05:31:46
skyblue_x=01/26/2014 at 05:31:46

There seams to be an extra = sign after date on the first person entered the rest are perfect in the ini.

Thanks again!


Edited by RuLerZ (26/01/14 04:54 AM)

Top
#244149 - 26/01/14 05:25 AM Re: get a list of everyone in the chan into a txt file [Re: RuLerZ]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3496
Loc: France
Try using $replacex instead of $replace, where are you testing this, which server?
Quote:
Since I Add people on join and remove people on part I found the need to use ini files for performance so
Tracking nicknames does not really require performance, only if you are tracking 80000+ nicknames at once. But the slowness before, was due to the while loop and the use of /write (which opens and closes the file each time you use it). INI files are stored in RAM and eventually flushed to the disk, which is why it's faster.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#244379 - 22/02/14 03:59 AM Re: get a list of everyone in the chan into a txt file [Re: Wims]
LizardJammer Offline
Nutrimatic drinks dispenser

Registered: 14/02/14
Posts: 9
I was looking to adapt this code to be used with hash tables but I cannot get the $crlf to make a new table entry. Here is what I have:
Code:
raw 353:& & #channame *:{
  /hadd -s inroom $replace($4-,$chr(32),$crlf)
}

Outcome:
Code:
BotNick

Nick1Nick2Nick3.....

Maybe there is a better way to add everyone in the room to a hash table, I was trying to write to a file then load the file into the hash table but was wondering if there was a cleaner way to do this?

Top
#244388 - 23/02/14 01:34 AM Re: get a list of everyone in the chan into a txt file [Re: Wims]
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
Hi Wims, I am using the bot on Twitch servers.

Also LizzardJammer, let me know if you get hash tables working with this, that would be instantly faster for me as well.


Edited by RuLerZ (23/02/14 01:35 AM)

Top