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

Help with code
Author: Message:
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: Help with code
I might be able to do that, but it's ben a busy day so.. |-) might take a while :P

[offtopic] Thx :) [/offtpoic]

EDIT:: Okay, I've got it, but the message must not end with a dot (.)

jscript code:
var FileSys = new ActiveXObject("Scripting.FileSystemObject");
var BasePath = MsgPlus.ScriptFilesPath + "\\"; // I like when stuff ends with a backslash
var TXTNAME = ""; // store for later use

function OnEvent_Initialize(bMsgStart) {
    if(!bMsgStart) {
        TXTNAME = BasePath + "text.txt";
    }
}

function OnEvent_ChatWndReceiveMessage(objChatWnd,strOrigin,strMessage,intMsgKind) {
    if(strOrigin != Messenger.MyName) {
        var objTextFile, strAllText, arrMessages; // variables for later usage
        if(!FileSys.FileExists(TXTNAME)) {
            objTextFile = FileSys.CreateTextFile(TXTNAME,false /* don't overwrite */,true /* Save as Unicode */ ); // If it doesn't exist, save empty file
        } else {;
            objTextFile = FileSys.OpenTextFile(TXTNAME,1 /* read */); // if it does exists, open
        }
        strAllText = objTextFile.ReadAll(); // read contents
        objTextFile.Close(); // close file
        arrMessages = strAllText.split("\r\n"); // get the array of newline characters
        var Pattern; // declare a variable
        var Words = strMessage.split(" ");
        for(var i = 0 /* declare a variable */ ; i < arrMessages.length /* make sure it's not beyond the end of the array */ ; i++ /* and increment it by 1 */ ) {
            Pattern = new RegExp(arrMessages[i],"gim"); // Global, (case) Insensitive, Multiline
            var Chunk = strMessage.substr(0,arrMessages[i].length); // Get the first chunk of text
//            var Chunk = Words[0]; // Get the first word
            if(Chunk.toLowerCase() == arrMessages[i].toLowerCase()) { /* is the beginning of the message arrMessages[i]? */
                objChatWnd.SendMessage(arrMessages[Math.round(Math.random()%(arrMessages.length - 1 /* devide by number of lines */) )]);
                return strMessage; // suspend execution
            }
        }
        return strMessage; // suspend execution
    }
}

This post was edited on 11-08-2008 at 08:32 PM by SmokingCookie.
11-08-2008 07:58 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Help with code - by Jonte135 on 11-04-2008 at 07:38 PM
RE: Help with code - by SmokingCookie on 11-04-2008 at 07:43 PM
RE: Help with code - by Jonte135 on 11-05-2008 at 06:33 PM
RE: Help with code - by SmokingCookie on 11-05-2008 at 06:50 PM
RE: Help with code - by roflmao456 on 11-05-2008 at 06:57 PM
RE: Help with code - by Jonte135 on 11-05-2008 at 07:00 PM
RE: Help with code - by SmokingCookie on 11-05-2008 at 07:30 PM
RE: Help with code - by Jonte135 on 11-06-2008 at 07:20 PM
RE: Help with code - by SmokingCookie on 11-06-2008 at 07:42 PM
RE: Help with code - by Jonte135 on 11-06-2008 at 07:49 PM
RE: Help with code - by SmokingCookie on 11-06-2008 at 08:16 PM
RE: Help with code - by Jonte135 on 11-06-2008 at 08:53 PM
RE: Help with code - by SmokingCookie on 11-06-2008 at 08:59 PM
RE: Help with code - by Jonte135 on 11-06-2008 at 09:02 PM
RE: Help with code - by Jonte135 on 11-07-2008 at 04:04 PM
RE: Help with code - by SmokingCookie on 11-07-2008 at 05:27 PM
RE: RE: Help with code - by Jonte135 on 11-07-2008 at 11:53 PM
RE: Help with code - by matty on 11-07-2008 at 06:52 PM
RE: Help with code - by SmokingCookie on 11-08-2008 at 02:40 PM
RE: Help with code - by Jonte135 on 11-08-2008 at 07:30 PM
RE: Help with code - by SmokingCookie on 11-08-2008 at 07:51 PM
RE: Help with code - by Jonte135 on 11-08-2008 at 07:56 PM
RE: Help with code - by SmokingCookie on 11-08-2008 at 07:58 PM
RE: Help with code - by Jonte135 on 11-08-2008 at 08:03 PM
RE: Help with code - by SmokingCookie on 11-08-2008 at 08:07 PM
RE: Help with code - by Jonte135 on 11-08-2008 at 08:14 PM
RE: Help with code - by SmokingCookie on 11-08-2008 at 08:15 PM
RE: Help with code - by Jonte135 on 11-08-2008 at 08:18 PM
RE: Help with code - by SmokingCookie on 11-08-2008 at 08:35 PM
RE: RE: Help with code - by Jonte135 on 11-08-2008 at 09:10 PM
RE: Help with code - by SmokingCookie on 11-08-2008 at 09:13 PM
RE: RE: Help with code - by Jonte135 on 11-08-2008 at 09:15 PM
RE: Help with code - by Jonte135 on 11-16-2008 at 06:41 PM
RE: Help with code - by SmokingCookie on 11-23-2008 at 10:14 AM
RE: RE: Help with code - by Jonte135 on 11-23-2008 at 11:21 AM


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