mIRC Home    About    Download    Register    News    Help

Print Thread
#131244 27/09/05 05:16 PM
Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
Ok, here's what Im trying to do:

Regardless of how many responses I get:
1) Take all ops out and put them on their own line
2) Take all voices out and put them on their own line
3) Take all regulars out and put them on their own line

The problem I have run into is this:

When I sort the output and try to grab the + or @ tokens, it takes the last token to the end of the line. How do I remove ONLY those nicknames with @ or + in them and parse them out - specifically to variables so I can put all ops on one line, voices on a second and the rest on a third.


Those who fail history are doomed to repeat it
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Someone else may be here who knows right off what to do with /names... but, I would only be able to help if you post a sample output from /names. I never use it and I'm behind a firewall right now, so I can't test it. If you want to post an output, I can help you... or, someone else who knows the output or can get it can help instead. smile

Also, it could help to see what you've tried to do. It may just be a small error in what you tried.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
The $sorttok outputs it like (sometimes on different lines - each line is sorted the same):

@Nick01 @Nick02 @Nick03 @Nick04 @Nick05 @Nick06 @Nick07 +Nick01 +Nick02 +Nick03 +Nick04 +Nick05 +Nick06 +Nick07 +Nick08 +Nick09 +Nick10 Nick01 Nick02 Nick03 Nick04 Nick05 Nick06 Nick07 Nick08 Nick09 Nick10 Nick11 Nick12 Nick13 Nick14 Nick15 Nick16 Nick17 Nick18 Nick19 Nick20 Nick21 Nick22 Nick23
#Channel End of /NAMES list.

raw 353:*://echa $sorttok($4-,32) | //halt
raw 366:*://echa $2- | //echs

echa is a custom alias:

Code:
/echa //echo -s 1,14 $+ $atime $+ 8 $1- 


Those who fail history are doomed to repeat it
Joined: May 2005
Posts: 79
M
Babel fish
Offline
Babel fish
M
Joined: May 2005
Posts: 79
This is what i do to make my names list like it is in the pic below, i'm sure you could split the alias and bits up to do what you want.

Code:
 alias  joinsync  {
  if ($me !ison $1) { halt }
  set %i 0
  set %nicks ""
  set %num 4
  echo $1 ÿ
  echo $1 ÿÿÿ00ÚÄÄÄÄÄ11ÄÄ0ÄÄÄÄ11ÄÄÄÄÄ10Ä11ÄÄÄ10ÄÄÄÄÿÄÄÿÿ14-ÿÿÿÿÿÿ14-ÿÿÿÿÿÿÿÿÿÿÿ10-
  echo $1 ÿÿÿ11ÀÄÄÄÄ--ÿ-ÿÿÄÄÿÿ-ÿÿÿ14[11s10ync $+ 14/00 $+ $calc(($ticks - %sync) / 1000) $+ s14]
  echo $1 ÿÿÿ00ÚÄÄÄÄÄ11ÄÄ0ÄÄÄÄ11ÄÄÄÄÄ10Ä11ÄÄÄ10ÄÄÄÄÿÄÄÿÿ14-ÿÿÿÿÿÿ14-ÿÿÿÿÿÿÿÿÿÿÿ10-
  :loop
  inc %i
  if (%i > $nick($1,0,a)) {
    if (%nicks != $null) {
      if ($numtok(%nicks,32) >= 1) { set %nicks %nicks | echo $1 ÿÿÿ11³ %nicks | goto end }
    }
    goto end
  }
  set %nicks %nicks  14[ $+ $xnames($nick($1,%i),$1) $+ 14]
  :next
  if (%i == %num) {
    echo $1 ÿÿÿ11³ %nicks
    set %num $calc(%num + 4)
    set %nicks ""
    goto loop
  }
  goto loop
  :end
  echo $1 ÿÿÿ11À00-ÿ00-Ä11-ÿ14-ÿÿÿÿÿ14-ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ14-ÿÿÿÿÿÿÿÿÿÿ10-
  echo $1 ÿÿÿ11ÚÄÄÄÄ--ÿ-ÿÿÄÄÿÿ-ÿÿÿ14[11 $+ #10 $+ $right($1,$calc($len($1) - 1)) $+ 14/00 $+ $nick($1,0,a) $+ 14]ÿÿÿÿ14[11q14/00 $+ $nick($1,0,q) $+ 14] 14[11o14/00 $+ $nick($1,0,o) $+ 14] 14[11n14/00 $+ $nick($1,0,r) $+ 14] 14[11v14/00 $+ $nick($1,0,v) $+ 14]
  echo $1 ÿÿÿ00ÀÄÄÄÄÄ11ÄÄ0ÄÄÄÄ11ÄÄÄÄÄ10Ä11ÄÄÄ10ÄÄÄÄÿÄÄÿÿ14-ÿÿÿÿÿÿ14-ÿÿÿÿÿÿÿÿÿÿÿ10- 
  echo $1 ÿ 
  remini data.ini joinsync $1
}


alias xnames {
  var %a $iif($2,$2,$chan),%x $iif($1 !isreg %a && $1 !ischan,+), %b $iif(%x,$left($nick(%a,$1).pnick,1)) $+ $1
  return $iif(%x,$+(,11,$left(%b,1))) $+ $str(ÿ,$calc(13 - $len(%b))) $+ $iif(%x,$+(15,$mid(%b,2,12)),$+(,15,$mid(%b,1,13)))
}

Raw 366:*:{ 
  set %sync $readini data.ini joinsync $2
  joinsync $2
  halt
}

on ^*:JOIN:#:{ 
  if ($nick = $me) {
    set %sync $readini data.ini joinsync #
    if (%sync == $null) { writeini data.ini joinsync # $ticks }
    halt
  }
}
 



pic here

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Try this (I'm assuming you have echs as a custom alias as well):

Code:
raw 353:*://sort $4- | //halt
raw 366:*://echa $2- | //echs


Code:
/echa //echo -s 1,14 $+ $atime $+ 8 $1- 

/sort {
  var %data = $sorttok($1-,32)
  var %c = 1
  while (%c <= $gettok(%data,0,32)) {
    if ($left($gettok(%data,%c,32),1) == @) { var %ops = %ops $gettok(%data,%c,32) }
    elseif ($left($gettok(%data,%c,32),1) == +) { var %voices = %voices $gettok(%data,%c,32) }
    else { var %regs = %regs $gettok(%data,%c,32) }
    inc %c
  }
  echa %ops
  echa %voices
  echa %regs
}


There may be a better way of doing it, but I am pretty sure that this works.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ewww! Goto! grin


Invision Support
#Invision on irc.irchighway.net
Joined: May 2005
Posts: 79
M
Babel fish
Offline
Babel fish
M
Joined: May 2005
Posts: 79
It's very old code, give or take a few bits, i've never bothered changing anything because i'm lazy and it seems to work ok, but if anyone fancies tidying it up for me, i'll give them a giant cookie grin

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I'm not sure I understand you correctly but I think this is what you want.
The following code will let you extract ops, voices or regulars from the names output:

Code:
alias parseops {
  var %ops
  return $null($regsub($1,/(?<= |^)[^@ ]+/g,,%ops)) %ops
}
alias parsevoices {
  var %voices
  return $null($regsub($1,/(?<= |^)[^+ ]+/g,,%voices)) %voices
}
alias parseregulars {
  var %regulars
  return $null($regsub($1,/(?<= |^)[@+][^ ]+/g,,%regulars)) %regulars
}


$parseops(output) - list of ops.
$parsevoices(output) - list of voices.
$parseregulars(output) - list of regulars.

Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
That's almost there. The ONLY other thing I'd like it to do is take ALL the ops (regardles of how many times it pumps out the raw code. But it does what I want it to partially smile


Those who fail history are doomed to repeat it
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
raw 353:*:{
  set %ops. $+ $2 $($+(%,ops.,$2),2) $parseops($4-)
  set %voices. $+ $2 $($+(%,voices.,$2),2) $parsevoices($4-)
  set %regulars. $+ $2 $($+(%,regulars.,$2),2) $parseregulars($4-)
}

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Regardless how many times it does the raw? Maybe changing the vars to sets would do what you need? You'd need to unset afterwards, of course.

Maybe make an alias to run names:
Code:
/mynames {
  unset %ops %voices %regs
  names $1-
}


Then, change these 3 lines:
Code:
    if ($left($gettok(%data,%c,32),1) == @) { var %ops = %ops $gettok(%data,%c,32) }
    elseif ($left($gettok(%data,%c,32),1) == +) { var %voices = %voices $gettok(%data,%c,32) }
    else { var %regs = %regs $gettok(%data,%c,32) }


to:

Code:
    if ($left($gettok(%data,%c,32),1) == @) { set %ops %ops $gettok(%data,%c,32) }
    elseif ($left($gettok(%data,%c,32),1) == +) { set %voices %voices $gettok(%data,%c,32) }
    else { set %regs %regs $gettok(%data,%c,32) }


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, the regsub will work better. I figured regex would probably be shorter, but I'm not well versed in it.

However, make sure you edit those parse sections so they are $1- and not $1.

And, you'll need to unset the variables at some point. You'll just need to figure out when to do it.


Invision Support
#Invision on irc.irchighway.net
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
$1 is fine. Identifier tokens ($1..$2..$N) are separated by commas (,), not spaces (same as using /tokenize 44 <string>).

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Hm... What he showed as sorted names used spaces. As such, it would need $1-. Where are you seeing it separated by something other than spaces?


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2004
Posts: 509
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Quote:
I'm not sure I understand you correctly but I think this is what you want.
The following code will let you extract ops, voices or regulars from the names output:

Code:
alias parseops {
  var %ops
  return $null($regsub($1,/(?&lt;= |^)[^@ ]+/g,,%ops)) %ops
}
alias parsevoices {
  var %voices
  return $null($regsub($1,/(?&lt;= |^)[^+ ]+/g,,%voices)) %voices
}
alias parseregulars {
  var %regulars
  return $null($regsub($1,/(?&lt;= |^)[@+][^ ]+/g,,%regulars)) %regulars
}


$parseops(output) - list of ops.
$parsevoices(output) - list of voices.
$parseregulars(output) - list of regulars.


How do we use $parseops? I tried //echo -a $parseops(output) and //echo -a $parseops(#channel), I get echo insufficient parameters. With the raw it works the same as a /names.

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You have to pass the output from /names to $parseops, for example:

Code:
$parseops(@Nick01 @Nick02 @Nick03 @Nick04 @Nick05 @Nick06 @Nick07 +Nick01 +Nick02 +Nick03 +Nick04 +Nick05 +Nick06 +Nick07 +Nick08 +Nick09 +Nick10 Nick01 Nick02 Nick03 Nick04 Nick05 Nick06 Nick07 Nick08 Nick09 Nick10 Nick11 Nick12 Nick13 Nick14 Nick15 Nick16 Nick17 Nick18 Nick19 Nick20 Nick21 Nick22 Nick23) = @Nick01 @Nick02 @Nick03 @Nick04 @Nick05 @Nick06 @Nick07

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
-DELETED-

Last edited by Riamus2; 28/09/05 05:10 PM.

Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard