quote:
Originally posted by Mattike
quote:
Originally posted by TheGuruSupremacy
quote:
Originally posted by Mattike
The advantage here is that it works for more than one word!
Also with split function works for more than one word
But not when you have "/command" in your actual message, read edited post.
I'm soo slow at editing...
It's improbably that "/command" is in message however
You are right split is not the best way to parse command...However
you can also do this:
code:
function OnGetScriptCommands(){
var commands = "<ScriptCommands>";
commands += " <Command>"
commands += " <Name>command</Name>"
commands += " <Description>TheGuruSupremacy</Description>"
commands += " </Command>"
commands += "</ScriptCommands>"
return commands;}
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if (Message.substring(0,8)=="/command"){
var url="http://www.yoursite.com/index.php?variable=" + Message.substring(8,Message.lenght)
Interop.Call("shell32","ShellExecuteW",0,"open",url,null,null,1)
MsgPlus.DisplayToast("Example",Message.substring(8,Message.lenght))
return "";}}
quote:
Originally posted by Mattike
Therefore, it's more common to use regular expressions. They're harder to understand and learn, but they avoid a lot of problems you can have when using such split() calls.
Yes it's true but is not necessary using regular expressions to parse a command..