mIRC Homepage
Posted By: krypto Replacing text on incoming messages - 06/09/12 06:08 PM
This is regarding the bug reported here:
https://forums.mirc.com/ubbthreads.php/topics/238811/mIRC_can_t_handle_URLs_properl

I hope that the bug is on the to-be-fixed list and will be fixed in the next release of mIRC, but just in case it isn't I already wrote a script that echoes the corrected url in the channel window when someone posts an url containing [] in it (%5B, %5D).

What I'm wondering is that is there a way to catch and replace the url or any text in a user's message directly? The echo seems a bit stupid and I'd like to replace the URL directly in the user's message, so it seems that they are posting the corrected (encoded) url.

A simple example will do on how to replace any text in the message itself, so it looks like the user is saying something different. Eg. user sends to a channel:

<User001> Hello.

and you see

<User001> Hi.
Posted By: Loki12583 Re: Replacing text on incoming messages - 06/09/12 07:36 PM
Echoing is the correct thing to do, just make sure you have all the switches to make it act like an incoming message.

The ^ event prefix allows you to use the haltdef command, this stops the default behavior of the event (displaying the text).

The $ event prefix is for using a regex for the match text, used here to match only lines containing http or www.

Code:
on ^$*:text:/http|www/iS:#:{
  echo -i2tbfmr # $+(<,$nick(#,$nick).pnick,>) $1-
  haltdef
}
Posted By: Tomao Re: Replacing text on incoming messages - 07/09/12 05:41 AM
It's better to use:
Code:
http\072\/\/|w{3}\.
For one, if someone bursts out entering "awwwwww," your text event will trigger.
Posted By: krypto Re: Replacing text on incoming messages - 07/09/12 08:09 AM
Doesn't really matter as the script won't do anything unless the url in the message contains those (referring to the link and problem in first message) special characters, but thanks for the tip Tomao.

A bit OT, but I have to say that mIRC's script looks horrible, it's like something out of Hoare's nightmares.
© mIRC Discussion Forums