Shoutbox

Nudge Open Chats - 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: Nudge Open Chats (/showthread.php?tid=93732)

Nudge Open Chats by vSanjo on 02-01-2010 at 03:18 PM

I'm having a little trouble with making a script for a friend that nudges open chats only.
I was planning on using /nudge to send them.
It seemed simple enough at first but I just can't manage it now.
Any help would be appreciated. (:


RE: Nudge Open Chats by matty on 02-01-2010 at 03:28 PM

Are you trying to nudge all open chat windows when you type /nudge?

Post your code and we can show you where you went wrong.


RE: Nudge Open Chats by vSanjo on 02-01-2010 at 03:44 PM

I haven't got any right now. It just wasn't working at all.
Ideally, I want to have a menu button to nudge all open contacts. I was planning on using some way to send /nudge to all chats.


RE: Nudge Open Chats by Mnjul on 02-01-2010 at 05:09 PM

Does simply sending /all /nudge work?


RE: Nudge Open Chats by Matti on 02-01-2010 at 05:16 PM

quote:
Originally posted by Mnjul
Does simply sending /all /nudge work?
Yes... that works apparently. :O
Just type that every time you need it or, if you really want to, make a quick text with a custom command for it. :)

Anyway, if you're looking to learn some scripting, this task can be a good exercise. When you got the command you're looking for when handling OnEvent_ChatWndSendMessage, iterate through the list of opened chat windows and send "/nudge" to each window. ;)
RE: Nudge Open Chats by vSanjo on 02-01-2010 at 11:35 PM

Gah. It seemed too simple so I didn't bother testing. I didn't think command + command would work!
*gonk*

Okay, I can do this. (:
And Matti, the main problem Iwas having -was- moving from chat to chat. ):


RE: Nudge Open Chats by matty on 02-02-2010 at 12:31 AM

Javascript code:
for (var oChat = new Enumerator(Messenger.CurrentChats); !oChat.atEnd(); oChat.moveNext()) {
    Debug.Trace(oChat.item().Handle);
}


RE: Nudge Open Chats by vSanjo on 02-02-2010 at 01:58 PM

I managed to make it work to a degree.

code:
function OnGetScriptMenu(Location)
{
    var ScriptMenu = "<ScriptMenu>";
    ScriptMenu += "<MenuEntry Id=\"nudgeall\">Nudge All</MenuEntry>";
    ScriptMenu += "</ScriptMenu>";
    return ScriptMenu;
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
    if(MenuItemId == "nudgeall")
    {
        if (Messenger.MyEmail == "sanjo@mapletip.com")
        {
            for (var oChat =  new Enumerator(Messenger.CurrentChats); !oChat.atEnd();  oChat.moveNext())
            {
                Debug.Trace(oChat.item().Handle);
                OriginWnd.SendMessage("/nudge");
            }
        }
        if (Messenger.MyEmail != "sanjo@mapletip.com")
        {
            OriginWnd.SendMessage("Not authorized!");
        }
    }
}


It sends a nudge to everyone, but if n is the amount of open chats, it does n*nudges to each chat.
Any way to fix this?

Edit: At first, I thought it was counting the nudges across chats, but if you change /nudge to like.. 'Rawr', it'll send n*rawr to each chat.

Edit 2:

code:
function OnGetScriptMenu(Location)
{
    var ScriptMenu = "<ScriptMenu>";
    ScriptMenu += "<MenuEntry Id=\"nudgeall\">Nudge All</MenuEntry>";
    ScriptMenu += "</ScriptMenu>";
    return ScriptMenu;
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
    if(MenuItemId == "nudgeall")
    {
        if (Messenger.MyEmail == "sanjo@mapletip.com")
        {
            for (var oChat =  new Enumerator(Messenger.CurrentChats); !oChat.atEnd();  oChat.moveNext())
            {
                Debug.Trace(oChat.item().Handle);

                OriginWnd.SendMessage("/nudge");
            }
        }

        if (Messenger.MyEmail != "sanjo@mapletip.com")
        {
            OriginWnd.SendMessage("Not authorized!");
        }
    }
}


I just removed the red.
See.. I was mixed up on 2 plans. 1 was to send /all /nudge to a single chat through a button, or /nudge to each contact through a button that goes through each chat.
I'm so silly.
RE: Nudge Open Chats by matty on 02-02-2010 at 02:49 PM

This is happening because the OriginWnd parameter of the OnEvent_MenuClicked event is the Chat Window where the menu is clicked. This will never change unless you click the menu from another Chat Window.

You would need to use:

Javascript code:
oChat.item().SendMessage('/nudge');


But you also want to make sure that you can send the message to begin with:

Javascript code:
function OnGetScriptMenu(Location) {
    return '<ScriptMenu><MenuEntry Id="nudgeall">Nudge All</MenuEntry></ScriptMenu>';
}
 
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd) {
    if (Messenger.MyEmail === 'sanjo@mapletip.com') {
        if(MenuItemId === "nudgeall") {
            for (var oChat =  new Enumerator(Messenger.CurrentChats); !oChat.atEnd();  oChat.moveNext()) {
                if (oChat.item().EditChangeAllowed === true) {
                    oChat.item().SendMessage('/nudge');
                }
            }
        }
    }
    else {
        OriginWnd.SendMessage('Not authorized!');
    }
}