Shoutbox

smarterchild reply (simple for most people) - 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: smarterchild reply (simple for most people) (/showthread.php?tid=78190)

smarterchild reply (simple for most people) by general sirhc on 10-14-2007 at 03:46 AM

I've just started making my second script ever and i'm still learning the ropes about how do things anyway so far i have got

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind){
if (Origin !== Messenger.MyName)
if (Origin !== '- SmarterChild - *unicef contributing to charity'){
Messenger.OpenChat('smarterchild@hotmail.com')
  Contacts = new Enumerator(ChatWnd.Contacts);
  Contacts.moveFirst;
  Contact = Contacts.item();
  Messenger.OpenChat(Contact.Email);
}
}

i'm trying to make it that when some1 sends you a message then you send the message to smarter child then when smarter child replys you send the reply to the person how sent you the message. any other help with scripting and i'll be thankful

SOMEONE PLEASE HELP!


RE: smarterchild reply (simple for most people) by win_crook on 10-14-2007 at 09:08 AM

This isn't actually that simple;
What about when there is multiple conversations? You would need some way of working out which conversation to send the correct smarterchild response back to.

I'll help with the receiving a message and then sending it to smarterchild part. But you or someone else will have to think of a way to code the sending the replys back part.

I'll write some code and an explanation for it, and put it in this post when I'm done ;)

EDIT:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
  var Contacts = Messenger.MyContacts;
  var sc = Contacts.GetContact('smarterchild@hotmail.com');
  if (Origin == sc.Name)
  {
    break;
  }
  if(MessageKind == 1)
  {
      var window = Messenger.OpenChat('smarterchild@hotmail.com');
      window.SendMessage(Message);
    }
  }
}


Okay and now for the explanation:
code:
  var Contacts = Messenger.MyContacts;
  var sc = Contacts.GetContact('smarterchild@hotmail.com');
  if (Origin == sc.Name)
  {
    break;
  }

1)We get the contact list using Messenger.MyContacts and store it in a variable called Contacts
2)Then we find smarterchild in this list and store it in sc
3)The if statement gets smarterchilds name from the sc we stored earlier and checks that the message wasn't from smarterchild. If it is we use break, which ends the currently running function. Therefore no more code is run and the message isn't sent.

code:
  if(MessageKind == 1)
  {
      var window = Messenger.OpenChat('smarterchild@hotmail.com');
      window.SendMessage(Message);
   }


1) MessageKind equals 1 when the message that has been recieved is text. Others can be winks, voice clips, searches etc... We won't be able to send those onto smarterchild so we simply ignore them by only accepting text messages by making sure MessageKind is 1.
2)We open a window with smarterchild and store it in window. If there is already a conversation open with smarterchild then the already open one is stored in window
3)Then we simply use window to send the message that we recieved.
RE: smarterchild reply (simple for most people) by vaccination on 10-14-2007 at 09:27 AM

I can only think of the implications. For example, most of the replies will have smarterchild spam like "Press 1 to.." and "Have you heard about..." Not only that but what if your contact asks a question related to you, personal question etc, smarterchild won't know the answer and will reply with something stupid. etc etc.




As for telling which reply goes with which message; time based? which ever question is sent fisrt, the first reply will be sent to them, second reply to second person etc. Though, there's still implications...


RE: smarterchild reply (simple for most people) by general sirhc on 10-14-2007 at 02:12 PM

i dont want smarter child to talk as me i just want it so its like a mocker (kinda like one of the old simple mockers that repeated what the person says back at them)

EDIT: win_crook thanx for the help but your code stuffed up with the

code:
  if (Origin == sc.Name)
  {
    break;
  }
  if(MessageKind == 1)
so i had to change it to
code:
var window = Messenger.OpenChat('smarterchild@hotmail.com');
window.SendMessage(Message);
which works ok but it keeps sending the message ( i think it was a glitch with msg plus not the code)
anyway thanks for the help and anymore you can offer