Shoutbox

auto messaging - 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: auto messaging (/showthread.php?tid=77309)

auto messaging by jollyscripts on 09-07-2007 at 06:55 PM

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {

    if(Origin != Messenger.MyName) {

        if(Message == "hi") {
       
           
         
            ChatWnd.SendMessage("hey, how r u")         
           
           
        }
    }
}

that is a script i wrote for my msn

now i want to be able to do the following

1) apply it to certain email addresses.
2) send it a certain amount of times

PLEASE HELP


RE: auto messaging by davidpolitis on 09-08-2007 at 04:58 PM

MessageKind is optional, it does not need to be declared in the function in this case...

Anyway... not sure if this is what you really wanted.

code:
//number of times to send message
var times = "2";

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message)
{
    if (Origin != Messenger.MyName)
    {
        if (Origin == "example@hotmail.com")
        {
            if (Message == "hi")
            {
                for(i=0; i<times; i++)
                {
                    ChatWnd.SendMessage("hey, how r u");   
                }     
            }
        }
    }
}

RE: auto messaging by Matti on 09-08-2007 at 06:24 PM

Sorry, but I have to note that Origin is the name of the user sending the message, and thus is not the e-mail address of the person. Therefore, you'd need to loop through the conversation contacts looking for the Origin, like this:

code:
//number of times to send message
var times = 2; //Why do you make this a string and force JScript to convert it to a number each time?

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message)
{
    if (Origin != Messenger.MyName)
    {
        //Start contact search
        var sEmail = ""; //Create a variable to store the e-mail in
        //Loop through the contacts in the chat
        for(var e = new Enumerator(ChatWnd.Contacts); !e.atEnd(); e.moveNext)
        {
            //If the contact's name matches the name of the sender...
            if (e.item().Name == Origin)
            {
                sEmail = e.item().Email; //Store the e-mail address
                break; //Exit the loop
            }
        }
        //End contact search
        if(sEmail == "example@hotmail.com")
        {
            if (Message == "hi")
            {
                for(i=0; i<times; i++)
                {
                    ChatWnd.SendMessage("hey, how r u");   
                }     
            }
        }
    }
}
If you mean with "send it a certain amount of times" that you want to set a maximum amount of times the message should be sent, it'll get a bit more complicated. I'll explain that if you really need to know. :)
RE: auto messaging by davidpolitis on 09-08-2007 at 08:58 PM

Sorry mattike, thanks for pointing that out.

I Just read in the doumentation that it'll return their nickname.