mIRC Homepage
Posted By: nomer2007 how to sort and save - 18/10/07 12:34 PM
when I join a chan a list of nicks will be posted on the status window. how can i save them to a textfile like nicks.txt

#channel LEeXen05 LADY_MAEVE ju22 jasper-x JrOcKiZThA rose19_dvo jm_ Guy_Wonder qc_male ^DRE^ Soul_M sexybabe XyPher_214 ana_alone OSS miSS_invisible kurusaKi_m luka_F ^^Andrea haizendhou` jesay24 Ruben`Gonzaga Lwin Nickname2 Hot_Men ^^BRyn^^ brent24 hyacinth isabelle_nicole im_alone attagirl_24 leia25 she_sk pJ17_AUdisTA TearHere`mDvO_ akoni Alexis`away cutie_nin08 HandsomeMARS_M AngGwapoKo nrop [mR-SmiLe] just_me-m safdfsd


gonna save it to the text file like


nick
nick
nick
nick
nick
nick
nick
nick


thanks for helping in advance
Posted By: 5618 Re: how to sort and save - 18/10/07 01:08 PM
try this:
Code:
raw 353:*:{
  var %nicks = $right($4-,-1)
  var %count = 1
  while ($gettok(%nicks,%count,32)) {
    write nicks.txt $gettok(%nicks,%count,32)
    inc %count
  }
}

As it is this will add the returned nicks to that file every time. If you want to delete the previous contents when receiving a new /names reply then just insert "write -c nicks.txt" above the for "var" line.
Posted By: nomer2007 Re: how to sort and save - 18/10/07 01:19 PM
it's working thanks...
one more question how can i read it using my bot and message the channel that i use !regnicks and messages the channel the regular nicks only

me: !regnicks

bot:nick1
bot:nick2
bot:nick3
and so on...


and then deletes the nicks..
Posted By: 5618 Re: how to sort and save - 18/10/07 01:32 PM
This code should be on the bot:
Code:
on *:TEXT:!regnicks:#channel:{
  while ($read(nicks.txt,1)) {
    msg $chan $read(nicks.txt,1)
    write -dl1 nicks.txt
  }
}  

something like that?
Posted By: nomer2007 Re: how to sort and save - 18/10/07 01:34 PM
i'll try it.. thanks


-

tried it but i got disconnected coz it msg the channel so fast
and it only gives back the 1st saved nick on the text file...
Posted By: Wims Re: how to sort and save - 18/10/07 01:38 PM
You can use $* and avoid the while :

Code:
raw 353:*:tokenize 32 $4- | write nicks.txt $*


And he can use /play to play the file when someone use !regnick :

Code:
on *:text:!regnick:#channel:play "nicks.txt"
Posted By: nomer2007 Re: how to sort and save - 18/10/07 01:42 PM
If i'll use play it'll give also the nicks that has @ or operator...
Posted By: Wims Re: how to sort and save - 18/10/07 01:48 PM
This is because i don't remove the sign of each nick (@,%,+) in the raw, but you can just add a $remove :

raw *:353:tokenize 32 $remove($4-,@,%,+) | write nicks.txt $*
on *:text:#channel:play "nicks.txt"

The play is better than the while in this case because by defaut, there are 1 second before mirc send each line.
Posted By: nomer2007 Re: how to sort and save - 18/10/07 01:54 PM
thanks but i'm looking for a code that'll save the nicks on a text file then
on a command gets the regular nicks only...
anyway very much thanks
Posted By: TropNul Re: how to sort and save - 18/10/07 01:57 PM
removing the status of each nick on receiving the names' raw may not be the better method because this will fill the file with all the nicknames without any way to distinguish between the nicknames later.

i think that there must be a filtering funtion if the user asks only for the regulars/voices/half-ops/ops.

[pseudocode]
open file
filter file
save result to a newfile
play newfile
delete newfile
[/pseudocode]

a better method would be to save the names in a hash table of an ini file. this will permet to 'index' any data that would be written. thus easing the retrieval for later use.

smile
Posted By: Wims Re: how to sort and save - 18/10/07 03:06 PM
If you just want to store the regular nick, you can use a regsubex that just tokenize the regular nick :

raw *:353:tokenize 32 $regsubex($4-,/((@|%|\+).\S+)/g,) | write nicks.txt $*
Posted By: Lpfix5 Re: how to sort and save - 18/10/07 03:43 PM
Um here you go, this will pop all names in tempa.txt then filter sort the nicks then !regnick will get only nicks without + or @ for nicks like !nick you will need to add another check in the if statement like I did for @ and +

Code:
raw 353:*:{ 
  var %x = 1
  .timer 1 3 /filter -ffac tempa.txt filter.txt 
  .timer 1 6 /.remove tempa.txt
  while (%x <= $numtok($4-,32)) {
    .write tempa.txt $gettok($4-,%x,32) $crlf
    inc %x
  }
}

on *:text:!regnick*:#channel:{
  var %x = 1
  while (%x <= $lines(filter.txt)) {
    if ($left($read(filter.txt,n,%x),1) == @) || ($v1 == +) { %inc x }
    else { echo -a $read(filter.txt,n,%x) }
    inc %x
  }
}
Posted By: Wims Re: how to sort and save - 18/10/07 05:27 PM
If he just want to have the regular nick, then my code do it but he said that he want to store all the nick and then check for the regular...
I think that if doesn't want to do anything with other nick, there is no reason to store them
Posted By: Lpfix5 Re: how to sort and save - 18/10/07 08:08 PM
But if he does the code is there.
Posted By: deegee Re: how to sort and save - 18/10/07 08:51 PM
Originally Posted By: Wims
If you just want to store the regular nick, you can use a regsubex that just tokenize the regular nick :

raw *:353:tokenize 32 $regsubex($4-,/((@|%|\+).\S+)/g,) | write nicks.txt $*

Or use $prefix wink
Code:
raw 366:*:if $me ison $2 { filter -wlfcxg $2 nicks.txt /[ $prefix ]/ }
on *:text:!regnick*:#channel:.play # nicks.txt | .remove nicks.txt
Posted By: nomer2007 Re: how to sort and save - 19/10/07 03:30 AM
Code:
raw 353:*:{ 
  var %x = 1
  .timer 1 3 /filter -ffac tempa.txt filter.txt 
  .timer 1 6 /.remove tempa.txt
  while (%x <= $numtok($4-,32)) {
    .write tempa.txt $gettok($4-,%x,32) $crlf
    inc %x
  }
}

on *:text:!regnick*:#channel:{
  var %x = 1
  while (%x <= $lines(filter.txt)) {
    if ($left($read(filter.txt,n,%x),1) == @) || ($v1 == +) { %inc x }
    else { echo -a $read(filter.txt,n,%x) }
    inc %x
  }
}



i'm using that but it only echoes isn't there anything you can do to use msg # and doesn't get disconnected coz of excess flood?
and not using play file
Posted By: Lpfix5 Re: how to sort and save - 19/10/07 06:20 AM
Originally Posted By: nomer2007
Code:
raw 353:*:{ 
  var %x = 1
  .timer 1 3 /filter -ffac tempa.txt filter.txt 
  .timer 1 6 /.remove tempa.txt
  while (%x <= $numtok($4-,32)) {
    .write tempa.txt $gettok($4-,%x,32) $crlf
    inc %x
  }
}

on *:text:!regnick*:#channel:{
  var %x = 1
  while (%x <= $lines(filter.txt)) {
    if ($left($read(filter.txt,n,%x),1) == @) || ($v1 == +) { %inc x }
    else { echo -a $read(filter.txt,n,%x) }
    inc %x
  }
}



i'm using that but it only echoes isn't there anything you can do to use msg # and doesn't get disconnected coz of excess flood?
and not using play file

]
Code:
raw 353:*:{ 
  var %x = 1
  .timer 1 3 /filter -ffac tempa.txt filter.txt 
  .timer 1 6 /.remove tempa.txt
  while (%x <= $numtok($4-,32)) {
    .write tempa.txt $gettok($4-,%x,32) $crlf
    inc %x
  }
}

on *:text:!regnick*:#channel:{
  var %x = 1
  while (%x <= $lines(filter.txt)) {
    if ($left($read(filter.txt,n,%x),1) == @) || ($v1 == +) { %inc x }
    else { .timer 1 1 /msg # $read(filter.txt,n,%x) }
    inc %x
  }
}

Posted By: nomer2007 Re: how to sort and save - 19/10/07 10:36 AM
why do i get
X Unknown command
Posted By: Doqnach Re: how to sort and save - 19/10/07 10:38 AM
there is a typo on a line:

Code:
if ($left($read(filter.txt,n,%x),1) == @) || ($v1 == +) { %inc x }


should be:

Code:
if ($left($read(filter.txt,n,%x),1) == @) || ($v1 == +) { inc %x }
Posted By: nomer2007 Re: how to sort and save - 19/10/07 12:23 PM
thanks that get rid of the error.

but still got this timer. even if it has a timer it still keeps on msg the channel to fast and the bot got disconnected..

oh and it hasn't deletes the nicks that has been said.
Posted By: 5618 Re: how to sort and save - 19/10/07 01:31 PM
Code:
on *:text:!regnick*:#channel:{
  var %x = 1
  while (%x <= $lines(filter.txt)) {
    if ($left($read(filter.txt,n,%x),1) == @) || ($v1 == +) { inc %x }
    else { .timer 1 1 msg # $read(filter.txt,n,%x) }
    inc %x
  }
}


That's because the code above sets all timers to 1 second,and since the script finishes almost instantaneously, they all end after 1 second. A fix for both your problems should be:

Code:
on *:text:!regnick*:#channel:{
  var %y = 1
  while ($read(filter.txt,n,1)) {
    if ($left($read(filter.txt,n,1),1) != @) && ($v1 != +) { .timer 1 %y msg $chan $read(filter.txt,n,1) | inc %y }
    write -dl1 filter.txt
  }
}
Posted By: Lpfix5 Re: how to sort and save - 19/10/07 04:02 PM
oops im sorry i forgot to increment within the statement very sorry
Posted By: nomer2007 Re: how to sort and save - 20/10/07 02:12 AM
works properly thanks...

how can i adjust the timer coz when it joined a big channel it get excess after20-30 nicks.. thanks
Posted By: Lpfix5 Re: how to sort and save - 20/10/07 03:06 AM
in the second snipplet the timer has a variable set called y if you change the var %y = numberhere then put the amount of seconds you want else if your editing a regular .timer its like this...

.timer 1(means repititions/How many times) 1(means seconds of timer) /command

.timer 1 2 /msg # I created a 2 second timer.
Posted By: nomer2007 Re: how to sort and save - 20/10/07 03:19 AM
ok got it thanks to you all
© mIRC Discussion Forums