Shoutbox

How to replace messeges - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: How to replace messeges (/showthread.php?tid=93482)

How to replace messeges by Barathrum on 01-09-2010 at 09:55 PM

I need script that does following:

Anything I type in chat window will be replaced with "/colorize" + text that was originaly writen

Example if i write in chat window "Hello, everyone" it will ouput "/colorize Hello, everyone"

Hope you understand what i mean.

Thanks for help


RE: How to replace messeges by Spunky on 01-10-2010 at 12:07 AM

Javascript code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
 return "/colorize " + Message
}


Although someone may want to add checks for things like commands being typed, this is a very basic way of doing it
RE: How to replace messeges by Barathrum on 01-10-2010 at 11:03 AM

Strange it does work, but when i try to send it simply says "The command you entered was not recognized" But when I manualy write infront a text /colorize and having this script disabled it works...


RE: How to replace messeges by Matti on 01-10-2010 at 02:40 PM

Unfortunately that's a nasty glitch from the Plus! engine. When an event is fired, such as OnEvent_ChatWndSendMessage, Plus! executes the event handlers from all enabled scripts in alphabetical order (A to Z).

If your script is named "My Script" and the Colorizer script is called "Colorizer", Colorizer will be executed first. It sees no command so it ignores the message. Your script then adds the command in front but it is no longer parsed by the Colorizer script.

Currently, the only workaround is to name your script something like "AAA - My Script" to make it execute its handlers before the Colorizer script. Another way would be to modify the Colorizer script yourself by removing the requirement for the /colorizer command.

Still, I don't recommend doing this for all messages. Adding /colorizer to every message without proper checks will block all other command from Plus! and any other script. Use some preliminary checks to make sure you're processing only non-command messages.


RE: How to replace messeges by Barathrum on 01-10-2010 at 03:17 PM

Well now I simply made that colorizer simply works for any message writen not with /colorize command . This seems like the best way :). Thank you both for answering.