Shoutbox

[Question] Messenger Plus! Commands - 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: [Question] Messenger Plus! Commands (/showthread.php?tid=67760)

[Question] Messenger Plus! Commands by Sana on 10-27-2006 at 11:03 PM

I'm new to scripting (and JavaScript >.>) so to test a couple things I just made a quick Shell script.

I used this code to place my Plus! command into the listbox:

code:
function OnGetScriptCommands() {
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>shell</Name>';
            commands+='<Description>Shell Execute</Description>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;   
}

And I used this to parse commands:

code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message) {
     if (Message.charAt(0) == "/") {
          if (Message.charAt(1) == "/") {
               return Message;
          }else{
               if (Message.charAt(6) == " ") {
                   if (Message.charAt(7) != "") {
                         Shell.ShellExecute(Message.substr(7));
   
                   }
               }
          }
     }
}

So for example, I can type "/shell notepad" and it shells notepad.exe, or "/shell www.google.com" and it opens Google in my browser.

It works in that it shells whatever parameter I specify, but it keeps giving me the Plus! error that I'm using an invalid command at the same time:

quote:
---------------------------
Messenger Plus! Live
---------------------------
The command you entered was not recognized.
If the message was not meant to be a command, insert a double '//' at its beginning.
---------------------------
OK   
---------------------------

I want to eliminate this error message, since "/shell" is in fact the command that I'm trying to use (and it actually does shell my parameter).

Any help would be appreciated.
RE: [Question] Messenger Plus! Commands by pollolibredegrasa on 10-27-2006 at 11:16 PM

Are there any errors in the script debugger?


RE: [Question] Messenger Plus! Commands by Spunky on 10-27-2006 at 11:20 PM

You may need to specify a paramater in the XML code =/


RE: [Question] Messenger Plus! Commands by Baggins on 10-28-2006 at 12:00 AM

code:
function OnGetScriptCommands() {
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>shell</Name>';
            commands+='<Description>Shell Execute</Description>';
            commands+='<Parameters/>
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;   
}
or something like that
RE: [Question] Messenger Plus! Commands by Plan-1130 on 10-28-2006 at 12:02 AM

It's because you didn't return anything, the code below should fix it...

code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message) {
     if (Message.charAt(0) == "/") {
          if (Message.charAt(1) == "/") {
               return Message;
          }else{
               if (Message.charAt(6) == " ") {
                   if (Message.charAt(7) != "") {
                         Shell.ShellExecute(Message.substr(7));
                         return "";
                   }
               }
          }
     }
}

Remember there might be malicuous contacts in your list who can abuse it and therby doing harmful things to you or your computer (if not, contactlists like urs are very rare, try posting a flooder here)
Also, your script seems to check for a lot of things, but it gets executed if you type "/blahh notepad" too.
A shorter, and better code would be:
code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message) {
     if (Message.substr(0,6) == "/shell ") {
          if (Message.substr(7) != "") {
               Shell.ShellExecute(Message.substr(7));
               return "";
          }
     }
}

And, I prefer to put a return before every bracket instead of putting it right behind the functionname or loop, it's up to you to decide what you think works easier, compare the previous one to thisone:
code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
     if (Message.substr(0,6) == "/shell ")
     {
          if (Message.substr(7) != "")
          {
               Shell.ShellExecute(Message.substr(7));
               return "";
          }
     }
}


RE: RE: [Question] Messenger Plus! Commands by Baggins on 10-28-2006 at 12:18 AM

quote:
Originally posted by Plan-1130
It's because you didn't return anything, the code below should fix it...
code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message) {
     if (Message.charAt(0) == "/") {
          if (Message.charAt(1) == "/") {
               return Message;
          }else{
               if (Message.charAt(6) == " ") {
                   if (Message.charAt(7) != "") {
                         Shell.ShellExecute(Message.substr(7));
                         return "";
                   }
               }
          }
     }
}


and also do this:D
RE: [Question] Messenger Plus! Commands by Sana on 10-28-2006 at 12:35 AM

Thanks for the help.

code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message) {
     if (Message.substr(0,7) == "/shell ") {
          Shell.ShellExecute(Message.substr(7));
          return "";
     }
}

RE: [Question] Messenger Plus! Commands by Spunky on 10-28-2006 at 07:42 AM

quote:
Originally posted by Plan-1130
Remember there might be malicuous contacts in your list who can abuse it and therby doing harmful things to you or your computer

You can't sent commands to this script remotely so I don't see anyway that a contact could abuse this...

Also, I know you were joking, but it may not be the best advice to tell someone to post a flooder ;) Some people would misunderstand and do it :p



RE: [Question] Messenger Plus! Commands by Plan-1130 on 10-29-2006 at 02:08 AM

Argh, you're right. I'm used to handling remote commands, which are catched in OnEvent_ChatWndReceiveMessage, thisone uses OnEvent_ChatWndSendMessage.
I'm sorry, noone can do harmful things with it, unless you make the command remotely accessible...