mIRC Home    About    Download    Register    News    Help

Print Thread
#206702 21/11/08 06:58 PM
B
Buggs2008
Buggs2008
B
Hello,


I'd like to find out if it's possible to have this while loop echo the output on one line instead of 2:

SERVER OUTPUT:

:IrcServer.1 319 Mynickname Buggs2008 :%#EspressoBar

:IrcServer.1 319 Mynickname Buggs2008 :%#test101

Code:
  if ($2 = 319) {
      var %x = $comchan($4,0)
      while (%x) {
        echo $comchan($4,%x)         14› $4 is in Channel(s): $5-
        dec %x 
    }
  }
 

MIRC OUTPUT (Current)

       14› Buggs2008 is in Channel(s): %#EspressoBar
       14› Buggs2008 is in Channel(s): %#test101


I would like to try and get the output one line of echo, I dont know if that possible though because the server is outputing a different channel for each 319 reply


WISHED FOR OUTPUT:

       14› Buggs2008 is in Channel(s): %#EspressoBar,%#test101

My only way of thinking of doing this maybe might be to use a hash table to store the data, then compare it, if there is one channel listed and there is not a second one, then the result is only one channel

On the other hand if there is one channel listed, store it, and if there is another one on a 319 reply, add it some how to the existing piece of data......thoughts?

Cheers

Jay

#206704 21/11/08 08:38 PM
Joined: Nov 2006
Posts: 1,552
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,552
The way I use whois raw events, in raw 319 (RPL_WHOISCHANNELS) "$2" (not $4) is "nick" and "$3-" (not $5-) the "chan(s)".
Anyway, a raw 318 (RPL_ENDOFWHOIS) is sent too (and afaik all IRCDs provide raw 318).
Due to the "end of whois" raw reply, you know that you have received all the data. Therefore you may store the raw 319 data temporary (maybe a %var and $addtok in your case; in one script I do a "re-sort" of the whole whois output to a single echo line, using a little hash table) and output the stored data on raw 318.

example (note: using your $4 and $5- values, but put in the raw events I'm used to) :
Code:
raw 319:*: {
  set -eu5 $+(%,chans.,$cid,.,$4) $addtok($($+(%,chans.,$cid,.,$4),2),$5-,9)
  ; haltdef?
}
raw 318:*: {
  if ($($+(%,chans.,$cid,.,$4),2)) {
    var %chans = $replace($v1,$chr(9),$+($chr(44),$chr(32))), %x = 1
    while ($comchan($4,%x)) {
      echo $v1 $4 is in channels: %chans
      inc %x
    }
  }
  unset $+(%,chans.,$cid,.,$4)
  ; haltdef?
}

It's adding the chans of all raw 319 to a variable %chans.<cid>.<nick> separated by $chr(9). These $chr(9) later are replaced, to get the desired "comma-space" delimited string of channels.

___________
EDIT:
A quick little script that might help you analyse raw replies and respecitve $Ns. Start/stop the output with /raws

Code:
alias raws {
  $iif(($group(#rawes) == on),.disable,.enable) #rawes 
  if ($group(#rawes) == on) { window -C @raws } 
  echo -g @raws * Output $iif(($group(#rawes) == on),started,stopped)
}

on *:close:@raws: { .disable #rawes }

#rawes off
raw *:*: {
  if ($numeric != 421) {
    var %n = 1, %rawline = $numeric 
    while ($($+($chr(36),%n),2) != $null) {
      var %rawline = $addtok(%rawline,$+($chr(3),$color(info2),[,$chr(36),%n,],$chr(3),$color(norm) $v1),32)
      inc %n
    }
    echo -gc info @raws %rawline
  }
}
#rawes end


Last edited by Horstl; 21/11/08 09:05 PM.

Link Copied to Clipboard