Shoutbox

Automated reply problem - 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: Automated reply problem (/showthread.php?tid=83370)

Automated reply problem by le-foot on 04-24-2008 at 02:59 PM

Hello,

I'm trying to write a script that sends some message back once a message has been sent. However, this


function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
    var Message = "Testing";
    ChatWnd.Sendmessage(Message);

}

seems to make it go in a continuous loop.

If it helps, how do I make use of parameters in OnEvent_ChatWndReceiveMessage?

Thanks


RE: Automated reply problem by MeEtc on 04-24-2008 at 03:13 PM

This is going into an infinite loop because OnEvent_ChatWndReceiveMessage is called when you send a message too! What you will want to do is compare the Origin parameter to your current display name. That will tell you if you are sending the message, or if its coming from your contact. One word of caution is that there are addons that can set a chat-only name (like StuffPlug) so you will also have to compare the chat only name as it is stored in the registry if you plan on using that feature any time in the future.

more info:
CookieRevised's reply to [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin


RE: Automated reply problem by le-foot on 04-24-2008 at 03:15 PM

Thanks for the reply. I see that is a problem, however I'm not familiar with using parameters. Could you give me an example, or point me to an example, of how a parameter is used in this case?

Thanks

EDIT: I'm trying to compare the names now, do you know what is the symbol for "does not equal"? In PHP it's "<>" but it gives me an syntax error.


RE: Automated reply problem by MeEtc on 04-24-2008 at 03:21 PM

I'm not quite sure what you mean by that... ?

ChatWnd is an object to reference the chat window itself
Origin is a string containing the display name of the suer sending the message
Message, is obvious I home
MessageKind is a numeric value From the scripting docs:

quote:
MSGKIND_UNKNOWN (0) - Unknown
MSGKIND_SAYS (1) -  Text message typed by the user
MSGKIND_WINKS (2) - A wink being sent
MSGKIND_VOICECLIPS (3) - A voice clip being sent
MSGKIND_SEARCHING (4) - A search made with the "Search" button
MSGKIND_FIND (5) - The result of a search made with "Search"
MSGKIND_SAYSOFFLINE (6) - A text message sent while the current user was offline
I would recommend using the numeric constants instead of the associated names.

I recommend you read a bit more thoroughly through the documentation for OnEvent_ChatWndReceiveMessage
RE: Automated reply problem by le-foot on 04-24-2008 at 03:23 PM

Yup sorry never mind.

Anyways in the previous post I added - how do I express "does not equal"? If I use "<>" I get syntax error.

Thanks


RE: Automated reply problem by MeEtc on 04-24-2008 at 03:26 PM

not equal is !=


RE: Automated reply problem by le-foot on 04-25-2008 at 02:29 AM

Ok so I try this:

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
    if(Origin != Messenger.MyName)
    {
    var Message = "Testing";
    ChatWnd.Sendmessage(Message);
    }
}

But it doesn't seem to go into the if statement. Where has my logic wrong?


RE: Automated reply problem by roflmao456 on 04-25-2008 at 02:38 AM

i think functions are case-sensitive so here's the fixed code

Sendmessage has to be SendMessage.

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Origin != Messenger.MyName){
var Message = "Testing";
ChatWnd.SendMessage(Message);
}
}

the code should work, only when a contact sends you a message :P
RE: Automated reply problem by le-foot on 04-25-2008 at 05:45 AM

>_<

It pays to activate the script

:$:$:$

(H)


RE: Automated reply problem by le-foot on 04-25-2008 at 09:06 AM

function OnEvent_ContactSignin(Email){
   
       
    var Message = "Hey";
    {______}.SendMessage(Message);
       
}

Okay, instead of when someone says something, I automatically say something when someone signs in.

Now do I put something in the {_____}?

Thanks


RE: RE: Automated reply problem by Veggie on 04-25-2008 at 10:45 AM

quote:
Originally posted by le-foot
function OnEvent_ContactSignin(Email){
   
       
    var Message = "Hey";
    {______}.SendMessage(Message);
       
}

Okay, instead of when someone says something, I automatically say something when someone signs in.

Now do I put something in the {_____}?

Thanks
code:
function OnEvent_ContactSignin(Email){
  var ChatWnd = Messenger.OpenChat(Email)
  var Message = "Hey";
  ChatWnd.SendMessage(Message);
}

Untested
RE: Automated reply problem by le-foot on 04-27-2008 at 06:27 AM

Thanks, that worked perfectly.:D


RE: Automated reply problem by le-foot on 05-02-2008 at 10:04 AM

is there an "Elseif" in the script? If so, what is the syntax?

I've tried Elseif, and Else If, but neither seems to be right.

Thanks


RE: Automated reply problem by Spunky on 05-02-2008 at 06:12 PM

if(condition){

}else if(condition2){

}else{

}