mIRC Homepage
Posted By: Deviance [6.x and 7.x] scid issue maybe - 21/07/10 12:00 PM
I happen to script a bot called DeviBOT and I noticed a little issue with scid. Say your in a channel named just # and I call a command for that channel that uses the scid command

ex: /scid 43 # blah

I end up getting a No such nick/channel. Is this a bug?, if not is there a way around this?
Posted By: Riamus2 Re: [6.x and 7.x] scid issue maybe - 21/07/10 03:06 PM
mIRC uses # as shorthand for $chan. It will try to evaluate to a channel. Although I don't know much about what should or shouldn't be allowed for channel names, I really don't think # should be a valid channel on any IRCD. You *might* be able to try something like ##, but I have no idea if that will work. You might also try using the $chr() equivalent of # and see if that works. Maybe someone else has some suggestions.
Posted By: drum Re: [6.x and 7.x] scid issue maybe - 21/07/10 04:00 PM
Actually # has historically been an allowed channel name on most IRCds, although some networks will choose to block it from use. For example, channel # exists on EFnet.

The original IRC specification states:

Quote:
Channels names are strings (beginning with a '&' or '#' character) of length up to 200 characters. Apart from the the requirement that the first character being either '&' or '#'; the only restriction on a channel name is that it may not contain any spaces (' '), a control G (^G or ASCII 7), or a comma (',' which is used as a list item separator by the protocol).


So, basically, # is a legal channel name by this definition. You would have to be very careful when creating mIRC scripts to be used in that channel, although I believe it's nothing that can't be worked around.
Posted By: argv0 Re: [6.x and 7.x] scid issue maybe - 21/07/10 04:32 PM
Escape the "#":

/scid 43 $chr(35) blah
Posted By: Deviance Re: [6.x and 7.x] scid issue maybe - 21/07/10 05:10 PM
Originally Posted By: argv0
Escape the "#":

/scid 43 $chr(35) blah


That workaround did the trick. Thanks and appreciated.
Posted By: drum Re: [6.x and 7.x] scid issue maybe - 21/07/10 06:48 PM
Unfortunately, the behavior is a little more tricky than suggested. In particular, the problem arises when using commands that cause double evaluation, such as /scid, /scon, /timer, and /flash. (Are there any others?)

Suppose you have the channel name stored inside $chan which would be a fairly common situation. As already mentioned, escaping it once can solve the problem. For example:

Code:
scid 43 msg $!chan hello


This would work because $!chan evalutes to $chan during the first evaluation, and $chan evalutes to the channel name during the second evaluation. It's critical to note that $chan is still a valid identifier when the second evaluation occurs. So, this method should work.

Timers are a more difficult problem to solve, however. The second evaluation occurs when $chan will no longer be retrievable. This means you MUST retrieve it during the first evaluation, but then it becomes more difficult to prevent the second evaluation from destroying # as a channel name.

For timers, this should solve the problem, although I suspect there might be a less confusing way that I can't think of right now:

Code:
timer 1 3 msg $!right(: $+ $chan $+ ,-1) hello!


I know your question didn't specifically deal with timers, but you'll likely run into the problem if you are dealing with the channel # in an mIRC script, so I thought it was relevant to point it out.
Posted By: Deviance Re: [6.x and 7.x] scid issue maybe - 22/07/10 01:00 AM
Well I am still having issues on this guys. What I'm doing is having it send by dde. My external app sends it out as this

/scid 1 msg $chr(35) Testing here

But I still get the No such nick/channel

It only does this if the channel name is only #
I have tested it to make sure the other rooms work. Any ideas on this? :P

Edit: When I do it just through mirc only without having my app send it through dde, it works. @_@

Another Edit: I tested it this way also through mirc only and it came up the same way. This is what I did.
/dde -e mIRC COMMAND /scid 1 msg $chr(25) hi

I also tried /dde -e mIRC COMMAND /scid 1 msg #test hi and that worked only on 6.35.
Posted By: argv0 Re: [6.x and 7.x] scid issue maybe - 22/07/10 01:18 AM
As drum stated, you need to escape any identifiers when passing to mIRC via script.

$!chr(35)
Posted By: Deviance Re: [6.x and 7.x] scid issue maybe - 22/07/10 01:25 AM
Originally Posted By: argv0
As drum stated, you need to escape any identifiers when passing to mIRC via script.

$!chr(35)


I've tried it that way and still a no go.

Edit: This method worked in 6.35 but not the latest beta.
Edit2: Nevermind I had a derp moment. Thanks guys.
Posted By: drum Re: [6.x and 7.x] scid issue maybe - 22/07/10 11:11 AM
Originally Posted By: drum
For timers, this should solve the problem, although I suspect there might be a less confusing way that I can't think of right now:

Code:
timer 1 3 msg $!right(: $+ $chan $+ ,-1) hello!


In case anyone was thinking of using this particular workaround, I just wanted to point out that this is not a good solution after all. It would break with many channel names, e.g., any channel with a parenthesis in the name. A proper solution would require a more complex solution like $encode/$decode.
Posted By: argv0 Re: [6.x and 7.x] scid issue maybe - 23/07/10 03:47 AM
All you really need is an $iif($len(#) == 1,$!!chr(35),#)

Replace "#" with $1 if it's coming from an alias. The OP was sending data via DDE, possibly from outside mIRC, so in that case the check would have to be done from that end, in whatever language is being used.

in a C-like lang: (input == "#" ? "$!chr(35)" : input)
© mIRC Discussion Forums