What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Need an example of proper /commands to show to other scripters

Need an example of proper /commands to show to other scripters
Author: Message:
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: Need an example of proper /commands to show to other scripters
I just wrote this, and I think it pretty much sums it up.
code:
// This function gets called when the user sends
// a message in a conversation. This is where we
// shall look for our command.
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  // Check if the message starts with "/", then
  // it is a command.
  if(Message.charAt(0) == "/")
  {
      // Split the string into smaller parts.
      var Parts = Message.split(" ");
      // Get the command name, and remove the first
      // character ("/").
      var CommandName = Parts[0].substr(1, Parts[0].length).toLowerCase();
     // Check if the command name is "command"
      if(CommandName == "command")
      {
        // If there are any parameters.
       if(Parts.length > 1)
       {
         // Show the first parameter in the debug window, there could be more.
         Debug.Trace("/command was called with parameter " + Parts[1]);
       }
       // Prevent the command from being sent.
       return "";
      }
      // Check if it's our second command.
      else if(CommandName == "command2")
      {
        if(Parts.length > 2)
        {
          // Parts[1] is the first parameter.
          // Parts[2] is the second parameter etc..
          Debug.Trace("/command2 was called with 2 parameters, " + Parts[1] + " and " + Parts[2]);
       }
       // Prevent the command from being sent.
       return "";
      }
  }
  // Send the message to the contact.
  return Message;
}

// This function gets called when Messenger Plus!
// gathers all commands available from your script
function OnGetScriptCommands( )
{
  // Start the ScriptCommands tag.
  var ScriptCommands = "<ScriptCommands>";
  // Add Command tags inside the ScriptCommand tag.
  // Note: Do not add the "/" character here.
  ScriptCommands += CreateCommand("command", "Command Description", "Parameter Description");
  // You can also add a command tag without my CreateCommand function.
  ScriptCommands += "<Command>";
  ScriptCommands += "<Name>";
  ScriptCommands += "command2";
  ScriptCommands += "</Name>";
  ScriptCommands += "<Description>";
  ScriptCommands += "Command2 description here!";
  ScriptCommands += "</Description>";
  ScriptCommands += "</Command>";
  // End the ScriptCommands tag.
  ScriptCommands += "</ScriptCommands>";
  // Return the commands to Messenger Plus!
  return ScriptCommands;
}

// This function returns the XML tag for a command.
function CreateCommand(Name, Description, Parameter)
{
  return "<Command><Name>" + Name + "</Name><Description>" + Description + "</Description><Parameters>&lt;" + Parameter + "&gt;</Parameters></Command>";
}
Feel free to edit my comments, my code. And use it however you want.
11-07-2007 08:29 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Need an example of proper /commands to show to other scripters - by Menthix on 12-19-2006 at 04:52 PM
RE: Need an example of proper /commands to show to other scripters - by vikke on 11-07-2007 at 08:29 PM
RE: Need an example of proper /commands to show to other scripters - by Spunky on 11-07-2007 at 09:32 PM
RE: Need an example of proper /commands to show to other scripters - by Menthix on 11-08-2007 at 06:43 AM
RE: Need an example of proper /commands to show to other scripters - by Felu on 11-08-2007 at 07:08 AM
RE: Need an example of proper /commands to show to other scripters - by vikke on 11-08-2007 at 05:50 PM
RE: Need an example of proper /commands to show to other scripters - by Spunky on 11-08-2007 at 06:51 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On