quote:
Originally posted by Leroux
javascript code:
var DM = "rpg1@hotmail.com";
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if ((Message =="/Test") && (Messenger.MyEmailAddress == DM))
{
var Message = "Testing";
MsgPlus.DisplayToast("Alert", Message);
}
}
Apologies for the bad code. I'm a little rusty, but you get the gist and hopefully it'll help you out a bit.
quote:
Return Value
A string containing the message to be sent instead of Message. If you do not want to modify the message, simply return Message without changing it. No size restriction applies to the new message except for the maximum size allowed by Messenger. If the event handler returns an empty string, the message is ignored and not sent to the server.
Problems:
1. You're setting the variable "Message", which is already set by OnEvent_ChatWndSendMessage
2. You aren't returning anything at the end of the event
3. Script commands should not start with an uppercase character (although they will still work)
4. Using OnGetScriptCommands(), along with our script command check, would be more suitable
Btw, I changed the one if to use two ifs so that "/test" isn't returned, causing a loop and script error, if the current user's email address is not the value of "DM". Also, "MyEmailAddress" is not a valid property of the Messenger object and was therefore changed to "MyEmail".
javascript code:
var DM = "email@live.com"; // Change to the 'enabled' email address
function OnGetScriptCommands()
{
var SC = "<ScriptCommands>";
SC += "<Command>";
SC += "<Name>test</Name>";
SC += "<Description>Test</Description>";
SC += "</Command>";
SC += "</ScriptCommands>";
return SC;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if (Message === "/test")
{
if (Messenger.MyEmail == DM)
{
var Msg = "Testing";
MsgPlus.DisplayToast("Alert", Msg);
}
return "";
}
return Message;
}
P.S. hopefully what I said makes sense. Sorry if it doesn't.