|
|
Joined: Jun 2003
Posts: 994
Hoopy frood
|
OP
Hoopy frood
Joined: Jun 2003
Posts: 994 |
I have a script that is looping through the nicklist of a channel and doing a whois on each. Everything works great except I sometimes get flooded off. Is there a method I can use to delay the increment of the variable so I can avoid this?
I refuse to engage in a battle of wits with an unarmed person.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
Nope, but you can do something like this: ; Delay between each whois in milliseconds (3000 = 3 seconds).
alias -l whois_delay { return 3000 }
alias whoisall {
var %i = 1
while ($nick($1,%i)) {
.timer -m 1 $calc((%i - 1) * $whois_delay) whois $v1
inc %i
}
} /whoisall <channel>
|
|
|
|
Joined: Dec 2002
Posts: 2,033
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,033 |
Why not just use timers?
alias mwhois {
var %i = 1,%ii = 0
while ($gettok($1-,%i,44) != $null) {
.timer 1 %ii whois $v1
inc %i
inc %ii 2
}
}
menu nicklist {
$iif(!$snick(#,0),$style(2)) Whois:mwhois $snicks
}
~ Edit ~
hixxy beat me to it 
|
|
|
|
Joined: Jun 2003
Posts: 994
Hoopy frood
|
OP
Hoopy frood
Joined: Jun 2003
Posts: 994 |
Thanks hixxy! As usual you've cut my coding in half with one that does more than my own did  ! Will you loan me your brain on weekends? Thanks to RoCk, as well 
Last edited by CtrlAltDel; 21/08/07 03:55 PM.
I refuse to engage in a battle of wits with an unarmed person.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
You don't want it, it's too distracted at the minute to be useful 
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Just a word of caution: the time it takes to create an unnamed timer in mirc grows very fast w.r.t. the number of existing unnamed timers (very roughly, if creating 100 unnamed timers takes 0.5 secs, creating 200 of them takes 0.5*10 = 5 secs). In practice, in a channel of 400 or more users, it becomes ridiculously slow. The simplest solution is to name the timers, for example .timermwhois $+ %ii 1 %ii whois $v1 or even .timer $+ %ii 1 %ii whois $v1
An even better solution imo would be to use a single timer; it requires some extra bookkeeping but it's less wasteful.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Just an amendment: reply-related loops are also possible without any timer Here is an example for using the "end of whois" to perform the next one (remove the filter part and add raw 401 to prevent break on part/quit/kick/nick of the whois'd user - it's just to get the main idea. add of joining nicks with /aline(nick), track of nickchanges with /rline(fline(nick)) and remove of nicks no longer valid with /dline(fline(nick)) would be possible, too)
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
When assigning a number to a new timer, mirc uses the first available number, starting from 1. So if you already have N timers running, each having a number from 1 to N, a new timer will be assigned N+1 but not before mirc checks all numbers from 1 to N to see if one of them is available for use. In rather technical terms, creating N unnamed timers this way can be no less than O(N^2). In mirc it's actually worse for some reason.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Thanks for the explanation. I'm glad I name my timers. 
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|
|