What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Scripting - help with commands (Was: HELP!)

Pages: (2): « First [ 1 ] 2 » Last »
Scripting - help with commands (Was: HELP!)
Author: Message:
Ashylay
Junior Member
**

Intermediate Scripter

Posts: 70
Reputation: 1
– / Male / –
Joined: Mar 2007
O.P. Undecided  Scripting - help with commands (Was: HELP!)
Okay so Im not the best at scripting and I was just wondering how this would happen.

So basically with the pre-installed scripts when you type say /name your name changes to whatever you type after the /name command so I just want to know how do you reffer to what you type after that.

I want it so say you type:

/command Hello!

A toast appears with the text 'Hello!'

Help?!?

This post was edited on 04-01-2007 at 01:21 PM by surfichris.
04-01-2007 12:47 PM
Profile E-Mail PM Find Quote Report
TheGuruSupremacy
Full Member
***

Avatar

Posts: 367
Reputation: 19
34 / Male / Flag
Joined: Nov 2006
RE: HELP!
quote:
Originally posted by Ashylay
Okay so Im not the best at scripting and I was just wondering how this would happen.

So basically with the pre-installed scripts when you type say /name your name changes to whatever you type after the /name command so I just want to know how do you reffer to what you type after that.

I want it so say you type:

/command Hello!

A toast appears with the text 'Hello!'

Help?!?




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){
var split=Message.split(" ")
if(split[0]=="/command"){
MsgPlus.DisplayToast("Example",split[1])
return "";}}


This post was edited on 04-01-2007 at 12:57 PM by TheGuruSupremacy.
04-01-2007 12:52 PM
Profile PM Find Quote Report
Ashylay
Junior Member
**

Intermediate Scripter

Posts: 70
Reputation: 1
– / Male / –
Joined: Mar 2007
O.P. RE: HELP!
Is there a possible way to involve this in a getURL function of some sort? && The above script only works with one word ;o

This post was edited on 04-01-2007 at 01:07 PM by Ashylay.
04-01-2007 01:00 PM
Profile E-Mail PM Find Quote Report
TheGuruSupremacy
Full Member
***

Avatar

Posts: 367
Reputation: 19
34 / Male / Flag
Joined: Nov 2006
RE: HELP!
quote:
Originally posted by Ashylay
Is there a possible way to involve this in a getURL function of some sort?

I don't understand....Involve in a geturl function????Tell me what you want to do....Try to explain it better...
04-01-2007 01:07 PM
Profile PM Find Quote Report
Ashylay
Junior Member
**

Intermediate Scripter

Posts: 70
Reputation: 1
– / Male / –
Joined: Mar 2007
O.P. RE: HELP!
Well say on a webpage you used a variable

Would it be possible to load an internet page which has a variable on it and use the writing you wrote as the varibale so some of the script would look like this:

"http://www.yoursite.com/index.php?variable=" + split[1]

Then it would load

http://www.yoursite.com/index.php?variable=WHATEVER YOU PUT FOR SPLIT 1
04-01-2007 01:13 PM
Profile E-Mail PM Find Quote Report
TheGuruSupremacy
Full Member
***

Avatar

Posts: 367
Reputation: 19
34 / Male / Flag
Joined: Nov 2006
RE: HELP!
quote:
Originally posted by Ashylay
Well say on a webpage you used a variable

Would it be possible to load an internet page which has a variable on it and use the writing you wrote as the varibale so some of the script would look like this:

"http://www.yoursite.com/index.php?variable=" + split[1]

Then it would load

http://www.yoursite.com/index.php?variable=WHATEVER YOU PUT FOR SPLIT 1


Ok...if i have understand well...you want 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){
var split=Message.split(" ")
if(split[0]=="/command"){
var url="http://www.yoursite.com/index.php?variable=" + split[1]
Interop.Call("shell32","ShellExecuteW",0,"open",url,null,null,1)
MsgPlus.DisplayToast("Example",split[1])
return "";}}


This post was edited on 04-01-2007 at 01:25 PM by TheGuruSupremacy.
04-01-2007 01:20 PM
Profile PM Find Quote Report
Ashylay
Junior Member
**

Intermediate Scripter

Posts: 70
Reputation: 1
– / Male / –
Joined: Mar 2007
O.P. RE: Scripting - help with commands (Was: HELP!)
Yes and also is it possible to use a for loop so I can type say

/command more than one word.
04-01-2007 01:25 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: HELP!
split() isn't the best way to parse command, regular expressions are more effective:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
   if(/^\/command\s(.+)$/i.test(Message)) { //Regular expression to do the check
      var Param = RegExp.$1; //Store Param, making the code easier to understand
      MsgPlus.DisplayToast("Example", "Opening page with parameter '"+Param+"'"); //Display a toast
      new ActiveXObject("WScript.Shell").Run("http://www.yoursite.com/index.php?variable="+escape(Param)); //Open the page with escaped Param to avoid any conflicts
      return ""; //Don't send the message, otherwise Plus! warns you that the command couldn't be parsed
}
Or, instead of using the ActiveX object, you could replace that rule with:
code:
Interop.Call("shell32", "ShellExecuteW", 0, "open", "http://www.yoursite.com/index.php?variable="+escape(Param), null, null, 1);

The advantage here is that it works for more than one word! :P


quote:
Originally posted by TheGuruSupremacy
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){
var split=Message.split("/command")
if(split[0]==""){
var url="http://www.yoursite.com/index.php?variable=" + split[1]
Interop.Call("shell32","ShellExecuteW",0,"open",url,null,null,1)
MsgPlus.DisplayToast("Example",split[1])
return "";}}

That code will work, but it will be case sensitive and it's not the recommend way to parse commands. Also, this won't work too good either with your code:
quote:
/command I'm testing this /command, funny huh!
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. ;)

This post was edited on 04-01-2007 at 01:32 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!
04-01-2007 01:26 PM
Profile E-Mail PM Web Find Quote Report
TheGuruSupremacy
Full Member
***

Avatar

Posts: 367
Reputation: 19
34 / Male / Flag
Joined: Nov 2006
RE: Scripting - help with commands (Was: HELP!)

quote:
Originally posted by Ashylay
Yes and also is it possible to use a for loop so I can type say

/command more than one word.

Yes..It's possible:

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){
var split=Message.split("/command")
if(split[0]==""){
var url="http://www.yoursite.com/index.php?variable=" + split[1]
Interop.Call("shell32","ShellExecuteW",0,"open",url,null,null,1)
MsgPlus.DisplayToast("Example",split[1])
return "";}}

04-01-2007 01:28 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Scripting - help with commands (Was: HELP!)
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...
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
04-01-2007 01:33 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« 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