What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Script to parse user input

Script to parse user input
Author: Message:
wiseguyxp
New Member
*


Posts: 8
Joined: Dec 2009
O.P. Script to parse user input
I am writing a script that will essentially create a new command for messenger.  I know that messenger has slash commands.  How do I add my script to the list of commands and pass it parameters?

If you can't pass parameters like that, I would like to scan the user's chat input and send the reformatted message.  I have done this already, but it always sends the original message also, since I'm using the OnEvent_ChatWndSendMessage function.  Is there any way I can intercept the user's input, modify it, then send it without displaying the user's original input?
12-06-2009 01:22 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Script to parse user input
I very strongly suggest you first read the official documentation. There it is very clearly explained how you do this basic stuff.

You can get the documentation by clicking on the menu "Files > Scripting Documentation" in the scripting editor.

If the help file is opened, navigate to the "Index" tab and click on "OnEvent_ChatWndSendMessage". There you'll see the whole explanation. Pay especially attention to "Return Value". It is this return value which will tell Plus! if the user has entered a recognized command or not and what the user will see after he entered a command.

A command is actually nothing more then just normal text. So the slash isn't actually needed; you can react on whatever you want. But to keep things simple and recognizable to the user, the consensus is that commands should always begin with a slash.

To learn how to add your own commands to the command list, see "Index > OnGetScriptCommands". Note that this has got nothing to do with actually letting Plus! recognize your commands, that is done in OnEvent_ChatWndSendMessage by the return value. OnGetScriptCommands simply adds your commands to the command list visible to the user, that's all. It's not mandatory, it is just good practice.

You can also take a look at existing small scripts.
;)

This post was edited on 12-06-2009 at 02:09 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-06-2009 02:06 AM
Profile PM Find Quote Report
wiseguyxp
New Member
*


Posts: 8
Joined: Dec 2009
O.P. RE: Script to parse user input
Yeah, I've been going through the official documentation in more detail since I posted the thread, so I figured out the whole return value thing from the docs and from others' scripts.

I really want to start my command with a slash, but when I had tried to use the slash command, it said "The command you entered was not recognized."  I took a look at OnGetScriptCommands (as you suggested) and it pointed to me to ScriptInfo.xml.  After defining the command in ScriptInfo.xml, it all works fine.  Thanks a lot!
12-06-2009 03:22 AM
Profile E-Mail PM Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: Script to parse user input
quote:
Originally posted by wiseguyxp
I really want to start my command with a slash, but when I had tried to use the slash command, it said "The command you entered was not recognized."  I took a look at OnGetScriptCommands (as you suggested) and it pointed to me to ScriptInfo.xml.  After defining the command in ScriptInfo.xml, it all works fine.  Thanks a lot!
you are also able to define a command in the script itself... most of the major script developers prefer this method (atleast i think they do =p)

the way to do it is to return the XML that you would normally place in the scriptinfo.xml when the function is fired...

jscript code:
function OnGetScriptCommands(){
    return '<XML CODE GOES IN HERE>';
}

hope this helps you out... and i look forward to seeing your script!

This post was edited on 12-06-2009 at 12:47 PM by NanaFreak.
12-06-2009 12:45 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Script to parse user input
quote:
Originally posted by wiseguyxp
I really want to start my command with a slash, but when I had tried to use the slash command, it said "The command you entered was not recognized."  I took a look at OnGetScriptCommands (as you suggested) and it pointed to me to ScriptInfo.xml.  After defining the command in ScriptInfo.xml, it all works fine.  Thanks a lot!
As I said before, the two things ("command not recognized" error and the OnGetScriptCommands() function) don't have anything to do with eachother.

OnGetScriptCommands() (or the equivalent in the ScriptInfo.xml which is indeed rarely used by scripters) simply lists your command in the command browser window which pops up when the user types a slash "/" in a conversation window. It does _not_ make the command 'recognizable' by Plus!, it simply adds the command to that list which has the sole purpose of displaying something to the user, nothing more.

You get the "command not recognized" error because you didn't tell Plus! that your script did recognize the text as a command. And that is done by returning something in the OnEvent_ChatWndSendMessage() function.

If you don't return something, Plus! will think that the command wasn't recognized by any installed and running script and will eventually show that error message after it has parsed that text to all the OnEvent_ChatWndSendMessage() functions in all the installed and running scripts.

To see an example of all that, see CookieRevised's reply to Gettin data from "/" commands.

PS: I didn't link to that before because (re)searching such things yourself is very vital to learn scripting in Plus!. :p

This post was edited on 12-07-2009 at 02:01 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-06-2009 04:51 PM
Profile PM Find Quote Report
wiseguyxp
New Member
*


Posts: 8
Joined: Dec 2009
O.P. RE: Script to parse user input
Oh okay, maybe I got that error in an older version of the script.  I didn't know that OnGetScriptCommands() was preferred.  I just picked ScriptInfo.xml because I wouldn't have to put all of the xml in quotes (laziness ftw).  But, I changed it to be more standardized and it all works fine still.
12-07-2009 05:46 AM
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