mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2010
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2010
Posts: 6
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?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
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.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Escape the "#":

/scid 43 $chr(35) blah


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: May 2010
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2010
Posts: 6
Originally Posted By: argv0
Escape the "#":

/scid 43 $chr(35) blah


That workaround did the trick. Thanks and appreciated.

Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
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.

Joined: May 2010
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2010
Posts: 6
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.

Last edited by Deviance; 22/07/10 01:07 AM.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
As drum stated, you need to escape any identifiers when passing to mIRC via script.

$!chr(35)


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: May 2010
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2010
Posts: 6
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.

Last edited by Deviance; 22/07/10 01:29 AM.
Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
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.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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)


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Link Copied to Clipboard