I'm afraid can't give you a complete description of how the code works because it uses a
regular expression. Regular expressions are basically a very powerful syntax used to match and capture text in a dynamic way. They're a very complex subject, there are dozens of books and technical manuals written on them, so it's beyond my abilities to explain them here properly. For a more detailed description see
Wikipedia.
Anyway, as for the rest of the code:
[color:blue]!.echo -q $regex(check_nets, %relayto, ^.+\x0312(.+)\]$)
msg #MyOtherChan $$regml(check_nets, 1)[/color]
- Well I guess you already know what the
echo command does so I'll skip that. The
! prefix forces mIRC to use the built-in
echo command and not use any aliases you might have defined - this is just a general precaution I take, it's not really specific to the task at hand. The
-q switch means that the
echo will be quiet (not echo anything) if the
. prefix has been used (which it has). It might seem completely useless at first to have an
echo command that doesn't actually echo anything, but it means that you can call identifiers and then ignore their results.
!.echo -q [color:blue]$regex(check_nets, %relayto, ^.+\x0312(.+)\]$)msg #MyOtherChan $$regml(check_nets, 1)[/color]
-
$regex is the identifier that utilises the regular expression I was talking about. The
check_nets parameter is just a name for the regular expression that I can refer to later to get the results of what it captured (the text you want to /msg).
%relayto is the input for the regular expression, so if you ever want to change what you input just edit this parameter.
^.+\x0312(.+)\]$ is the regular expression itself, the part that does most of the work but that I can't explain so I won't try to.
!.echo -q $regex(check_nets, %relayto, ^.+\x0312(.+)\]$)
msg #MyOtherChan [color:blue]$$regml(check_nets, 1)[/color]
-
$regml is the identifier which is used to return the results of a previous call to $regex. I've used a double
$$ so that if the regex didn't match anything (ie. if the %relayto variable wasn't in the format you expected) it won't cause an error. The
check_nets is of course the name of the regular expression used earlier, the
1 simply means it will return the first (and in this case only) captured text.