Shoutbox

My First Script, some problems - 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: My First Script, some problems (/showthread.php?tid=86929)

My First Script, some problems by Xat on 10-28-2008 at 04:14 PM

Hi !

I want make a script, but I haven't knowledge on JS scripting...

What my script must do normally :

  • When I type a command, send a message
  • these commands run only if the beginning of the mail adress of my contct is "XXX" (for example)

If someone can help me... Here's what I did :
code:
function OnGetScriptCommands()
{
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>command1</Name>';
            commands+='<Description>cmd1.</Description>';
            commands+='<Parameters/>';
        commands+='</Command>';
        commands+='<Command>';
            commands+='<Name>command2</Name>';
            commands+='<Description>cmd2.</Description>';
            commands+='<Parameters/>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;
}


function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if (Message=="/command1")
{
            chat_window.SendMessage("command1");
            return "";
    }
    else
    {
    if (Message=="/command2")
    {
            chat_window.SendMessage("command2");
            return ""; }   
            }
            }

RE: My First Script, some problems by matty on 10-28-2008 at 04:52 PM

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
    if (Message === "/command1") {
        ChatWnd.SendMessage("command1");
        return "";
    } else if (Message === "/command2") {
        ChatWnd.SendMessage("command2");
        return "";
    }   
}

RE: My First Script, some problems by MeEtc on 10-28-2008 at 05:20 PM

yeah, I'm helping him on WLM right now. Xat is trying to listen for a command and only do stuff when in certain chat windows. Here's what we have so far:

code:

function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    for (var e = new Enumerator(ChatWnd.Contacts); !e.atEnd(); e.moveNext()) {
      c = ChatWnd.Contacts.GetContact();
      if (c.Email.substring(0,6) = 'mgroup') {

         // do stuff, check the message for commands

      } else {
         return '';
   }
}