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

Getting started
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Getting started
Well, the idea you have comes with a variety of possible problems. :D

First of all, you'll need to find a way not to respond to your own messages. That means, if you respond on "hi" with "hi there!", you have to avoid responding on "hi there!" too.

Secondly, you'll need a proper way to find the messages you're looking for. You could go the easy way and simply use:
code:
if(Message.indexOf("hi") !== -1) {
but that won't match "Hi" or "HI". Also, you might want to avoid matching "hitch" as well. That's where regular expressions can come in handy, such as:
code:
if(/\bhi\b/\b.test(Message)) {
However, that may already be quite advanced, so maybe you should first learn about those when you plan to do it really good. :)

But your basic concept may look like:
code:
var Match = {
   "hi" => "Hello there! :)",
   "how are you" => "I'm fine, thanks! ;)"
};

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, Kind) {
   //1. Check if the message was sent by a contact and not yourself.
   //2. Loop through the Matches with for(var Key in Matches) {}.
   //3. Match the key against the Message.
   //4. If a match was found, send the respond message (Matches[Key]) and return to prevent multiple responses for one message.
}
A good trick to get around the first problem is by using a timer of 1 second when a message is sent by you. That will set a global variable (such as bDoNotRespond) to true. Then, when the timer runs out, you set it back to false. You can now check in the receive message event first if bDoNotRespond is true, and then cancel the timer and return immediately to prevent responding to your own messages. That way, you don't need to use all kinds of workarounds to match Origin against the right contact name. ;) (Think about custom nicknames, StuffPlug's timestamps,...)

Anyway, I'm sure there are a lot of threads here which may help you with this. Good luck! :)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-18-2008 09:28 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Getting started - by Jonte135 on 10-12-2008 at 02:41 PM
RE: Getting started - by Matti on 10-18-2008 at 06:57 PM
RE: Getting started - by Jonte135 on 10-18-2008 at 07:03 PM
RE: Getting started - by Matti on 10-18-2008 at 09:28 PM
RE: Getting started - by Jonte135 on 10-18-2008 at 10:11 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