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:
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. Getting started
I've downloaded the Scripting Documentation and read until "Your first script". What's the next step? It doesn't really explain much more after that ^o)

Thanks :)
10-12-2008 02:41 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: Getting started
When you finished reading the Getting Started section, you're ready to pick up an idea and make it a Plus! Live script. :)

This will mean a lot of trial and error, I can assure you that. Think about something you want to try out, then think how you'd convert that idea into code. It really depends on what you want to do, it's impossible to give an all-round solution for each possible idea. Try to come up with something interesting which you might find useful, and then be creative. It may help if you already have some programming experience, if not you might run into difficulties understanding the thinking process of writing a program.

If you ever need help with how to execute a certain idea, don't hesitate to ask here. We'll see if your idea is technologically possible with the current possibilities of the scripting engine and help you with finding a good approach for your code. Just try to avoid asking for completely functioning code - you'll learn much more when you write your code yourself! ;)
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 06:57 PM
Profile E-Mail PM Web Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Getting started
Ahh ok thanks, well I already have an idea which is a simple bot that will answer on questions etc. For example if someone says "hi" to me it will answer back. How to do that is the problem though :(
10-18-2008 07:03 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: 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
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Getting started
Thanks a lot! I have thread that I made, click here, and I will be going from there to make the rest :)
10-18-2008 10:11 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