What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » can somebody code a simple script for me?

can somebody code a simple script for me?
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: can somebody code a simple script for me?
Not sure if this fixes the problem or not but have a go at it.

js code:
// Declare our custom Contacts object
var oContacts = {} ;
// Declare the message to send
var sMessage = 'This is the message to be sent' ;

function OnEvent_ChatWndSendMessage ( pChatWnd , sMessage ) {
    // Check if the message is /sendall
    if ( sMessage.match ( /\/sendall/i ) ) {
        // Enumerate the Contact List
        for ( var oContact = new Enumerator ( Messenger.MyContacts ) ; !oContact.atEnd() ; oContact.moveNext() ) {
            // Store the contacts in our custom contacts object
            oContacts [ oContact.item().Email ] = oContact.item() ;
        }
        // Add the timer
        MsgPlus.AddTimer ( '' , 60000 ) ;
        // Return a blank string to tell Plus! to ignore the command we are sending
        return '' ;
    }
}

function OnEvent_Timer ( sTimerId ) {
    // Initialize counter
    var i=0;
    // Loop through custom contact object
    for ( var oContact in oContacts ) {
        // Check if the contact isn't offline, blocked or ourselves
        if ( oContacts [ oContact ].Status !== STATUS_OFFLINE &&
             oContacts [ oContact ].Blocked === false &&
             oContacts [ oContact ].Email !== Messenger.MyEmail ) {
            // Open chat window for the contact
            var oChatWnd = Messenger.OpenChat ( oContact ) ;
            // Check if we are allowed to send a message
            if ( oChatWnd.EditChangeAllowed === true ) {
                // Send the message
                oChatWnd.SendMessage ( sMessage ) ;
            } else {
                // Close the Chat Window if we are not allowed to send a message
                Interop.Call ( 'user32' , 'SendMessageW' , oChatWnd.Handle , 0x10 /* WM_CLOSE */ , 0 , 0 ) ;
            }
        // Delete the contact from our object as they are no longer needed
        delete oContacts [ oContact ] ;
        // Increment our counter
        ++i ;
        // Check if our counter has reached the limit per minute
        if ( i === 8 ) { // Was 10 is now 8 as per MeEtc's comments
            // Exit the loop
            break ;
        }
    }
    // Readd the timer
    MsgPlus.AddTimer ( '' , 60000 ) ;
}
10-28-2009 02:51 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
can somebody code a simple script for me? - by XTRC on 10-27-2009 at 04:41 PM
RE: can somebody code a simple script for me? - by tony on 10-27-2009 at 05:04 PM
RE: can somebody code a simple script for me? - by XTRC on 10-27-2009 at 07:10 PM
RE: can somebody code a simple script for me? - by MeEtc on 10-27-2009 at 07:15 PM
RE: can somebody code a simple script for me? - by matty on 10-27-2009 at 07:22 PM
RE: can somebody code a simple script for me? - by XTRC on 10-27-2009 at 07:34 PM
RE: can somebody code a simple script for me? - by matty on 10-28-2009 at 02: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