|
|
Joined: Nov 2009
Posts: 81
Babel fish
|
OP
Babel fish
Joined: Nov 2009
Posts: 81 |
//echo $chan(any string) == $chan(0) i think thats not normal
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
In a lot of place in mIRC, an invalid parameter is considered as 0. It could be fixed to return $null but that's not really important
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Aug 2010
Posts: 134
Vogon poet
|
Vogon poet
Joined: Aug 2010
Posts: 134 |
Well, the downside is that you can't quickly check if a parameter is an existing channel. You'd first have to check if the leftmost character is found in $chantypes.
Note that $chan(#anytext) DOES return $null and not $chan(0), assuming you're not on #anytext.
Learning something new every day.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Two options:
if ($chan(somettext).status isalpha) { } if ($window(somettext)) { }
The first tells you it's a valid channel that you have open. The second tells you if it's a valid window that is open -- good for checks that aren't likely to be true due to a query window or chat having the same name.
In option 1, you can also check only joined or the other types of statuses if that's useful for your script. Not really sure what your script's purpose is, so not sure what the best way to handle it would be.
As a note, $read() got changed as far as how it handled invalid strings placed into the identifier. That should be a good indicator that it's not a good idea to skip "real" checks by expecting an invalid parameter to return $null. In other words, rather than trying to use $null to know if it's a valid channel (even if it works), you would be better off using some other actual command that would tell you like the examples above rather than hoping that $chan() with invalid parameters returns $null and not an error or some other value. Just something to consider for this any all other types of commands.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
If it's a channel, then if ($me ison #chan) will be true, which you should use to check if the channel is an "existing channel".
I'm not quite sure what you're reporting, otherwise-- you should obviously check that your channel input is a valid channel input before passing data around to identifiers. $chan() expects proper input.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
'ischan' should be used to check if it's a valid channel
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Dec 2002
Posts: 344
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Dec 2002
Posts: 344 |
'ischan' should be used to check if it's a valid channel Unfortunately, "ischan" has the quirk that it will report true when a channel window is open but the server is disconnected. "ison" will give false in this case. I guess there may be situations where you would want either behavior, but you should be aware that they aren't completely interchangeable.
|
|
|
|
Joined: Nov 2009
Posts: 81
Babel fish
|
OP
Babel fish
Joined: Nov 2009
Posts: 81 |
I use $query($nick) for query check, $chat($nick) for dcc chat check and I just wanna using $chan(#) for channel check. I want clear code alias say {
var %target = $active, %str = $1-
if ($chan(%target)) msg $v1 %str
elseif ($query(%target)) msg $v1 %str
}
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
You know that you can use just $active with /say, right? There's no reason to check anything.
say { msg $active $1- }
Of course, say already does that, so there's no reason to change it.
So I'm not sure what your example is supposed to show or why you think that's "clear" when it can be done the way I just showed. For other things that won't use $active, you might consider $target. Or, something like $iif($chan,$chan,$nick) or something along those lines.
If you'd like help making "clear code", then please display the real reason you need to do what you're trying to do and someone can show you how to do that cleanly.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|
|