What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Disable automatic reply

Disable automatic reply
Author: Message:
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. Disable automatic reply
Well I made this code/someone helped me with it. Anyway what it does is that everytime someone say "Hey" to me I reply "Hi <their name>! Time to chat again :)". Now if the user says "Hey" again I want me to not reply back again. This is my code:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
var variable = 0;
}

 

if (Message.match("Hey") && variable == 0)
{
ChatWnd.SendMessage('Hi ' + Origin + '! Time to chat again :)');
variable = 1;
}
else
{
ChatWnd.SendMessage(':yay:');
}


function OnEvent_Uninitialize(MessengerExit)
{

}


And the :yay: thingy is just there so I know it works, I will delete that later when it works ;) Just one problem... it doesn't work :P So please help (A)

This post was edited on 10-06-2007 at 11:16 AM by Jonte135.
10-06-2007 11:16 AM
Profile E-Mail PM Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: Disable automatic reply
ok, here you go:

code:
var SentAlready = new Array();

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
    SentAlready[ChatWnd.Handle] = 0;

    if(Message.match("Hey") && SentAlready[ChatWnd.Handle] == 0){
        ChatWnd.SendMessage('Hi ' + Origin + '! Time to chat again :)');
        SentAlready[ChatWnd.Handle] = 1;
    }else{
        ChatWnd.SendMessage(':yay:');
    }
}

function OnEvent_ChatWndDestroyed(ChatWnd){
    if(SentAlready[ChatWnd.Handle]) SentAlready[ChatWnd.Handle] = 0;
}

NOTE: i have not tested this, and if you contact says "alfdsgakljfgnklas Hey knsdfkljgn balh" it will send the message stuff.

NOTE 2: this will (should) reset when you close the chat window... if you dont want that to happen, just take out the last function

This post was edited on 10-06-2007 at 11:37 AM by NanaFreak.
10-06-2007 11:33 AM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: RE: Disable automatic reply
NanaFreak, please beware that this won't work. You first set the SentAlready[ChatWnd.Handle] to 0 every time a message is received, even after you have set it to 1.

The correct way would be to do something like this:
code:
var SentAlready = new Array();

function OnEvent_ChatWndCreated(ChatWnd){
    SentAlready[ChatWnd.Handle] = 0; //Set an element when a ChatWnd is opened
}

function OnEvent_ChatWndDestroyed(ChatWnd){
    SentAlready.splice(ChatWnd.Handle, 1); //Delete the element when the ChatWnd is destroyed
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
    if(Message.match("Hey") && SentAlready[ChatWnd.Handle] == 0){
        ChatWnd.SendMessage('Hi ' + Origin + '! Time to chat again :)');
        SentAlready[ChatWnd.Handle] = 1;
    }else{
        ChatWnd.SendMessage(':yay:');
    }
}
See? When a ChatWnd is created, an element in the array is set to 0. When "Hey" is received, that element is set to 1. When the ChatWnd is destroyed, the element is removed. ;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-06-2007 12:05 PM
Profile E-Mail PM Web Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Disable automatic reply
It's not working.
10-06-2007 01:12 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Disable automatic reply
quote:
Originally posted by Jonte135
It's not working.
What's the problem? Can you please tell us what the debugger says when you do this? (Contact List > Scripts Icon > Script debugger > Choose your script from the list, then try to re-produce the problem)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-06-2007 02:05 PM
Profile E-Mail PM Web Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Disable automatic reply
Ok it's working when I'm saying Hey, but not when my contact is.
10-06-2007 06:14 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Disable automatic reply
Maybe it's because you're matching it case-sensitive. Try to replace
code:
Message.match("Hey")
with
code:
/hey/i.test(Message)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-06-2007 06:38 PM
Profile E-Mail PM Web Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Disable automatic reply
Still not working.
10-06-2007 06:41 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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