mIRC Home    About    Download    Register    News    Help

Print Thread
#217851 23/01/10 11:02 AM
Joined: Jan 2010
Posts: 1
O
Oasiz Offline OP
Mostly harmless
OP Offline
Mostly harmless
O
Joined: Jan 2010
Posts: 1
Hello,

Using $chan within a timer function fails on IRCX extended channels ("%#" prefix).

e.g
Code:
on 1:JOIN:#: {
  if ($nick != $me) {
    .timer 1 2 /msg $chan Welcome $nick
  }
}


Regards

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The command part of a timer will always be evaluated.
In the moment you start the timer, $chan will become e.g. %#chan. Then, in the moment the timer is executed, %#chan would be treated as a variable (i.e. evaluated to the value of that variable %#chan, which most likely is "nothing").

Note that it may be a security issue if you don't account for that extra evaluation (e.g. for #$chan_named_like_an_identifier).
Here are some additional infos and two methods for bypassing this "extra" evaluation. Suggestion:
Code:
on 1:JOIN:#: {
  if ($nick != $me) {
    .timer 1 2 msg $safe2($chan) Welcome $nick
  }
}
alias safe2 { bset -t &a 1 $1 | return $!regsubex(safe, $bvar(&a,1-) ,/(\d+)(?: |$)/g,$chr(\1)) }



Joined: Jul 2008
Posts: 236
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
See Wims' followup for the reason that particular solution is broken. It needs a bunset in there.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
In fact there's no problem with the actual code for safe2 while the alias is only called one time in the same *scope* because binvar are local


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard