What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [help!] how to make my own /sevil

[help!] how to make my own /sevil
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [help!] how to make my own /sevil
The best way to parse commands is to use regular expressions. An example would be:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    var checkExp = /^\/testcmd/i
    if(checkExp.test(Message)){
        return "I've send you a test command!"
    }
}
var checkExp = /^\/testcmd/i declares a new regular expression object, which will give a match when the input string begins with "/testcmd". A regular expression is always placed between two slashes and ends in an optional flag, in this case the i flag which specifies that the expression is not case-sensitive. The ^ defines the beginning of the string and the slash is escaped by a backslash. (otherwise you should get an error)

The test() method of the regular expression object returns true when the input string matches the expression, otherwise it returns false. This method is very handy for making an if-statement to check if the message matches and then execute a block of code.

The OnEvent_ChatWndSendMessage event can return a new message which will replace the entered message. In this case, instead of sending "/mycommand" to your contact, it'll send "I've send you a test command!".

And there you have the basics of script command parsing! ;)

This post was edited on 10-19-2006 at 05:43 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-19-2006 05:37 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[help!] how to make my own /sevil - by guardian-of-souls on 10-19-2006 at 03:45 PM
RE: [help!] how to make my own /sevil - by Felu on 10-19-2006 at 03:54 PM
RE: [help!] how to make my own /sevil - by guardian-of-souls on 10-19-2006 at 04:14 PM
RE: [help!] how to make my own /sevil - by Plik on 10-19-2006 at 04:28 PM
RE: [help!] how to make my own /sevil - by guardian-of-souls on 10-19-2006 at 05:01 PM
RE: [help!] how to make my own /sevil - by Matti on 10-19-2006 at 05:37 PM
RE: [help!] how to make my own /sevil - by guardian-of-souls on 10-19-2006 at 05:46 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