What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Need Help with my First Script

Need Help with my First Script
Author: Message:
SamV522
New Member
*


Posts: 10
Joined: Nov 2009
O.P. RE: Need Help with my First Script
AwayI.js
js code:
// Name: AwayI.js
// Author: SamV522
// Purpose: A.I. to respond to any messages while you're away.

var AI = {};
AI.Name = "Sophie";
AI.UnkownResponse = "I do not know how to respond to that, sorry.";
AI.Status = true;
AI.Responses = {};
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

function verify(){
    if (xmlDoc.readyState != 4){
        return false;
    }
}

function loadXML(xmlFile)
{
    xmlDoc.async="false";
    xmlDoc.onreadystatechange=verify;
    xmlDoc.load(xmlFile);
    xmlObj=xmlDoc.documentElement;
}

function OnEvent_SigninReady()
{
    if( AI.Status){
        loadXML("coms.xml");
        var In = "";
        var Out = "";
        for(i=0;i!=xmlObj.childNodes.length;i++){
            if(xmlObj.childNodes(i).childNodes(0).getAttribute("CaseSenseitive")=="false"){
                // The response IS case sensitive
                In = xmlObj.childNodes(i).childNodes(0).text;
                In = In.split(",");
                Out = xmlObj.childNodes(i).childNodes(1).text;
                Out = Out.split(",");
                for(i2=0;i2!=In.length;i2++){
                    AI.Responses[In[i2]].Resp = Out;
                    AI.Responses[In[i2]].CaseSens = false;
                }
            }else{
               
            }
        }
    }
}

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin, Message, MessageKind)
{
    var inMsg = Message;
    var resp = "Error!";
    for(i=0;i!=AI.Responses.length;i++){
        if(AI.Responses[Message]){
            if(AI.Responses[Message].CaseSens){
                inMsg = inMsg.toLowerCase();
            }else{
                inMsg = inMsg;
            }
           
            if(inMsg==AI.Responses[inMsg]){
                resp = AI.Responses[Message][Math.floor(Math.random()*Responses[Message].length)];
            }else{
                resp = AI.UnkownResponse;
            }
        }
        ChatWnd.SendMessage(resp);
    }
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    if (Message.substr(0,6).toLowerCase() == "/AwayI"){
        var param = Message.substr(7);
        switch(param){
            case "enable":
                AI.State = true;
                return "";
            case "disable":
                AI.State = false;
                return "";
            case "commands":
                var WindowOptions=MsgPlus.CreateWnd("Commands.xml","CommandsWND");
                return "";
            /*default:
                alert("Invalid Command! Type \"/AwayI Commands\" to see a list of valid commands");
                break;
                */
        }
    }
}

function OnEvent_MenuClicked(sMenuId, nLocation, ChatWnd)
{
    switch(sMenuId){
        case "enableAI":
            AI.Status = true;
            break;
        case "disableAI":
            AI.Status = false;
            break;
        case "commandList":
            var WindowOptions=MsgPlus.CreateWnd("Interfaces.xml","commandsWND");
            break;
    }
}

ScriptInfo.xml:
xml code:
<?xml version="1.0"?>
<ScriptInfo xmlns="urn:msgplus:scripts" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="1.0">
<Information>
    <Name>AwayI MSN Bot</Name>
    <Description>An MSN Bot by SamV522</Description>
    <Version>1.0</Version>
</Information>
<ScriptMenu>
    <MenuEntry Id="enableAI">Enable</MenuEntry>
    <MenuEntry Id="disableAI">Disable</MenuEntry>
    <MenuEntry Id="commandList">Commands</MenuEntry>
</ScriptMenu>

<ScriptCommands>
    <Command>
        <Name>AwayI</Name>
        <Description>Execute an AwayI command</Description>
        <Parameters>&lt;Command&gt;</Parameters>
    </Command>
</ScriptCommands>
</ScriptInfo>
11-24-2009 07:23 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Need Help with my First Script - by SamV522 on 11-24-2009 at 04:54 PM
RE: Need Help with my First Script - by SourSpud on 11-24-2009 at 04:58 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 05:00 PM
RE: Need Help with my First Script - by SourSpud on 11-24-2009 at 05:02 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 05:12 PM
RE: Need Help with my First Script - by CookieRevised on 11-24-2009 at 05:14 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 05:43 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 06:10 PM
RE: Need Help with my First Script - by matty on 11-24-2009 at 06:20 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 06:24 PM
RE: Need Help with my First Script - by Spunky on 11-24-2009 at 06:25 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 06:32 PM
RE: Need Help with my First Script - by matty on 11-24-2009 at 06:53 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 07:16 PM
RE: Need Help with my First Script - by matty on 11-24-2009 at 07:19 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 07:23 PM
RE: Need Help with my First Script - by SamV522 on 11-24-2009 at 07:55 PM
RE: Need Help with my First Script - by Spunky on 11-24-2009 at 08:00 PM
RE: Need Help with my First Script - by matty on 11-24-2009 at 08:29 PM
RE: Need Help with my First Script - by CookieRevised on 11-24-2009 at 08:35 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