mIRC Home    About    Download    Register    News    Help

Print Thread
who loop prob #180551 11/07/07 01:09 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I have this loop in my script:
Code:
alias who-cline {
  var %g = 1
  while ($chan(0) >= %g) {
    who $chan(%g)
    inc %g
  }
}

and im not shure if this is the best way to do what i want, i coloring the nick's in nicklist, i have colors for op/opers/vo/notify/ignore/away and regular users, the problem i have is that if i join many channels at once, then the code make me flood out, and i cant get it to stop doing this, i dont know how i can solve this problem. any ideas would be nice. the rest of the code is this:
Code:
raw 352:*: {
  haltdef
  if ($me !ison $2) { return }
  elseif (* isin $7) { cline $clinecol(po) $2 $6 }
  elseif ($6 isnotify) { cline $clinecol(no) $2 $6 }
  elseif (G isin $7) { cline $clinecol(aw) $2 $6 }
}

alias clinecol {
 if ($1 == po) { return 05 }
 if ($1 == no) { return 03 }
 if ($1 == aw) { return 02 }
}

the rest of the colors are grabed by the users status on the channel so i using two aliases for the coloring.

po = oper
no = notify
aw = away

PS: it's impossible to grab oper/ignore/away in any other way then use /who ?


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: who loop prob [Re: sparta] #180552 11/07/07 01:35 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The way of keeping that from flooding out, is to put the raw response section into a group that is enabled just before you do the /who and disabled when raw 315 is returned.

Here's your code with that modification, and another suggestion regarding the clinecol alias
Code:
alias who-cline {
  var %g = 1
  while ($chan(0) >= %g) {
    .enable #who-cline
    who $chan(%g)
    inc %g
  }
}
#who-cline off
raw 352:*: {
  if ($me !ison $2) { return }
  elseif (* isin $7) { cline $clinecol(po) $2 $6 }
  elseif ($6 isnotify) { cline $clinecol(no) $2 $6 }
  elseif (G isin $7) { cline $clinecol(aw) $2 $6 }
  halt
}
raw 315:*:{
  .disable #who-cline
  haltdef
}
alias clinecol {
  return $iif($1 == po,05,$iif($1 == no,03,$iif($1 == aw,02)))
}
#who-cline end


Regarding getting that information from something other than /who, not that I'm aware of anything.

Last edited by RusselB; 11/07/07 01:36 AM.
Re: who loop prob [Re: sparta] #180555 11/07/07 04:02 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Originally Posted By: sparta
i have colors for op/opers/vo/notify/ignore/away and regular users


First of all, put op/voice/regular/ignore/notify into your address book without worrying about looping. That saves some checks. That leaves you with only needing to check opers (I assume you mean ircops?) and away. Note that you can also color nicks based on idle time (not really away, but similar).

For the away and ircop status, you'd probably still have to /who everyone. Still, that cuts down on your need to check things, which should help.


Invision Support
#Invision on irc.irchighway.net
Re: who loop prob [Re: RusselB] #180565 11/07/07 10:23 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Thnx, i try use #group and see if it helps, and why i dont use the address book to color the nick's in the list is this, it's not that easy to setup, if you are new to mirc and want to change the colors, then it's much easyer to just click on a icon with the color you want, then youre done. if you could write to the address book and change the colors that way it would be nice, but what i know you cant. anyone that do have the time to explain a bit on how to make this ?

;------------ Edit

Now i have been trying out #group, how ever i still got one problem, when i joined the channels "on connect", then i got like 5 channels to do /who on, and the script does, how ever i cant do much other things while the script updates it self, how can i make it do the who a bit slower, like this: /who #channel1 . when channel 1 is done /who #channel2 and when channel 2 is done /who #channel3 and so on? now it get the /who from all the channels at the same time, this mean it will lag for a while, and i cant figure out how to do this.

Last edited by sparta; 11/07/07 11:08 AM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: who loop prob [Re: sparta] #180569 11/07/07 01:59 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
/help /cnick

Set all nicks in your notify list to color 04:
/cnick -y * 04

Set all nicks in your ignore list to color 05:
/cnick -i * 04

-o = op, -v = voice, -p = protect, -IN = Idle for N seconds (I is capital)

Rather than -o or -v for op/voice, you can also use the modes themselves, which lets you handle other modes (halfop, admin, founder, etc) if those are available on your network:
/cnick * 04 @
/cnick * 05 +
/cnick * 06 !
/cnick * 07 %

For regular nicks, use:
/cnick * 08

To remove colors from the list, use -r.

You can easily set those up in a script (dialog or popup or whatever) so that you can select the color(s) you want from there rather than using the address book. Remember when setting them that the order is important. Whichever color you set first will override the other colors if there are multiple matches on a single nick.

For example, if I am both @ and +, and the @ color was entered first, I will be that color. If the + was entered first, then I'll be that color instead. By putting all of this into a script, you won't have to worry about it as long as you put them in the order you want. Normally, you want to put the modes in order from highest mode to lowest mode (@ then + then the regular nicks one shown above, for example). For other types of colors, you have to decide if you want them to override the modes. If you use idle time, you probably want that to be first so that all idle nicks change to the idle color instead of their mode color. The same for notify, ircop, and ignore. So, you'd set those first, then the modes, then the regular (all users) color.

Note that you can set a different color for those with multiple modes/etc.

Example:
/cnick * @ 04
/cnick -I60 * @ 05

That will make the normal ops red, and the idle ops dark red. It won't affect anyone else who is idle... just ops (@ and -IN are combined into one). You can combine modes as well:

/cnick * @+ 02

Or whatever.

Put this into a script for on START as well as into whatever dialog or whatever you're using for setting them. For on START, make sure that you store the colors that are chosen in the dialog so that they are available for on START.


Invision Support
#Invision on irc.irchighway.net
Re: who loop prob [Re: Riamus2] #180589 11/07/07 08:21 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Since i want to return if a nick is irc operator or if the nick is set away i need to use /who nick , then filter the info from that, how ever i cant solve it, if i do /who * o , that should return all irc operators in the channel, how ever i only can get it to cline the irc operator in the first channel he are on. same with away users, the code i use looks like:
Code:
/testar trigger it.

alias testar {
  var %chna = $chan(0)
  var %chni = 1
  while (%chni <= %chna) {
    cli $chan(%chni)
    inc %chni
  }
}
alias cli {
  var %i = $nick($1,0)
  while (%i) {
    who $nick($1,%i)
    ; the echo return all the nicks in the channel.
    echo -a -> $nick($1,%i)
    dec %i
  }
}
raw 352:*: {
  if ($6 ison $2) {
    ; the echo here also return all nick's in the channel,
    ; it also echo the status, so nothing wrong here.
    echo -a -> $6 - $7
    if (* isin $7) { cline $clinecol(po) $2 $6 }
    if (G isin $7) { cline $clinecol(aw) $2 $6 }
    haltdef
  }
}
alias clinecol {
  if ($1 == po) { return 05 }
  if ($1 == aw) { return 02 }
}

so the error must be in the line where i color the nick, i tested to use:

cline -l $clinecol(po) $2 $6
cline -l $clinecol(aw) $2 $6

same thing, it wont color the nick in the channel, any ideas on this one? need help to solve this problem.

and Riamus2, i have the colors setup already for the others, and since that wont cose any lag or problem i stick with the alias wink thnx anyway for the explanation, lerned a bit of it smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: who loop prob [Re: sparta] #180591 11/07/07 08:43 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
That's up to you. Keep in mind that joining a channel with hundreds of users could cause lag when you try to /cline every single user in the channel, where the address book option produces no lag at all. Just something to keep in mind.

As for the ircops, again, use the address book. Get the nick and/or address of the ircop from /who and then add that nick to the address book in line 1 (or at least somewhere above the mode colors if used, as I explained why order is important). That will change the ircop's color in all channels. And, again, it's faster than having to /cline the user in every channel.

I'd recommend clearing the address book colors every time you start mIRC and then resetting them so that it's always accurate. You'll be doing a /who every time you (or someone else) joins a channel, so you'll be updating it anyhow. No need to keep it there and perhaps have it go out of date.


Invision Support
#Invision on irc.irchighway.net
Re: who loop prob [Re: Riamus2] #180596 11/07/07 09:02 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
The problem i cant solve is the /who command, i cant get it to ether do /who #channel on all channels without cosing me to lag or flood me out "if i join many channels on connect", and even due i set the color to the address book or not i still need the /who command, that is the problem i have with it.

;------ Edit
Havent seen any script with color on away/irc operators befor, else i could have looked at that and maybe that would have helped me to solve the /who problem, another way maybe would be to use $ial, how ever i never used it and have no clue on how to get the info from that.

Last edited by sparta; 11/07/07 09:05 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: who loop prob [Re: sparta] #180597 11/07/07 09:39 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
But that's the point: your $ial will not be up-to-date when you join a chan. You have to /who all chan(s) to update your ial.
Try to delay the /who commands with a timer, or something like :

- set up a variable "%whochans" (this could also be a hashtable)

- on joining channels:
--- if there is no data in %whochans (it's the first chan you join) - who that chan
--- if there is data in %whochans (a who reply did not finish yet), add the new chans-to-who to that variable ($addtok)

- on raw "end of who":
--- if that chan is in %whochans, remove it from that data ($remtok)
--- if there is still data in %whochans (there are other chans-to-who waiting), who the next chan ($gettok).

This creats a "loop" that will not who all chans at once, (lag? floodkill?) but gradually (takes more time).

$chan(#name/N).inwho and $ial(#name/N).ial might also help.

You do not need the $ial (or who-replies) to colour nicks according to their channel status, as Riamus showed above.
But, if you want to use data like "ircop status" etc, store all data you need temporarily (grab the raw replies of /who and add user levels, or create a hash table, or...). This should not cause any lag. Having who'd all chans, and having all the data you need, colour them like Riamus suggested.

Re: who loop prob [Re: Horstl] #180622 12/07/07 09:38 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Now i have this while loop.
Code:
alias testar {
  var %i = $chan(0)
  while (%i) {
    var %ic = $chan(%i) 
    var %ci = $addtok(%ci,%ic,44)  
    dec %i
  }
  set %tx %ci
  var %xt = 1
  while ($gettok(%tx,%xt,44) != $null) {
    echo -a -> $gettok(%tx,%xt,44)
    inc %xt
  }
}

how ever i'm not shure how to add a timer to this, the line that would need the timer is the last echo "echo -a -> $gettok(%tx,%xt,44)" , i need to calc the timer from how many channels it's in the %tx var, then increase the timer for the next channel, then go on doing that untill the channels = $null "$gettok(%tx,%xt,44)", how would i do that? explain plz.

Last edited by sparta; 12/07/07 09:50 AM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: who loop prob [Re: sparta] #180658 12/07/07 05:47 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Couldent edit my last post.

alias testar {
var %i = $regsubex($Str($chr(32) $+ ~,$chan(0)),/~/g,$chan(\n))
echo -a %i
}

this is what i have so far, it return

#channel #channel1 #channel2

how can i make this use the first string in the %var, then trigger a script with that one, then use the next string in the %var and trigger a command, and i want to do this untill it's epmty "got to the end in the %var", i have no clue on how to "halt" the script, that wait befor it start the next one. explain plz..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: who loop prob [Re: sparta] #180662 12/07/07 08:04 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Some Examples...

a) Make a string of all chans separated by $chr(32).
Code:
alias allchans {
  var %nr = 1
  while ($chan(%nr)) {
    var %chans = $addtok(%chans,$ifmatch,32)
    inc %nr
  }
  echo -a I made this string: %chans
}

b) Start timers directly out of the loop - this avoids storing any data in a variable.
Code:
alias looptimer { 
  var %nr = 1
  while ($chan(%nr)) {
    timer 1 %nr echo -t $ifmatch now I trigger here in $ifmatch - thats chan No. %nr
    inc %nr
  }
}

c) Make a numbered string of all chans (in the format nr1 chan2•nr2 chan2•nr3 chan3...), THEN loop all tokens of that string, and use the 2 parts of each token (nr and channelname) to start timers.
The $calc part was to show that you can manipulate the timer's offset as you like.
Code:
alias stringtimer {
  var %nr = 1
  while ($chan(%nr)) {
    var %chans = $addtok(%chans,%nr $ifmatch,149)
    inc %nr
  }

  echo -a now I got this string: %chans

  var %nr = 1
  while $gettok(%chans,%nr,149) {
    var %token = $ifmatch
    timer 1 $calc($gettok(%token,1,32) *3) echo -t $gettok(%token,2,32) now I trigger here.
    inc %nr
  }
}

Instead of "echo" or "echo -t" in the examples, you can trigger every command (or alias) you want. And of course, silence the timers.... with .timer

Re: who loop prob [Re: Horstl] #180679 12/07/07 10:50 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
thnx, i read the info you gave me and giv it a try smile will try to make my own loop, thnx for the explanation smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }