Okay, here goes...
I'm making an Instant Response script, which is currently controlled entirely from the script menu, but I'm now adding /commands, which are as follows:
js code:
function OnGetScriptCommands()
{
var ScriptCommands = "<ScriptCommands>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.enable</Name>";
ScriptCommands += "<Description>Turn Instant Response on.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.disable</Name>";
ScriptCommands += "<Description>Turn Instant Response off.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.message</Name>";
ScriptCommands += "<Description>Change the Instant Response message.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.timer</Name>";
ScriptCommands += "<Description>Change the Instant Response timer.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.pluson</Name>";
ScriptCommands += "<Description>Turn the Instant Response Plus! Style on.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.plusoff</Name>";
ScriptCommands += "<Description>Turn the Instant Response Plus! Style off.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.alerton</Name>";
ScriptCommands += "<Description>Turn the Instant Response sign-in alert on.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.alertoff</Name>";
ScriptCommands += "<Description>Turn the Instant Response sign-in alert off.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>ir.status</Name>";
ScriptCommands += "<Description>Check the status of Instant Response.</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
That bit works fine, but it's the programming bit that's causing trouble...
js code:
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage)
{
if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMessage) !== null)
{
var command = RegExp.$1.toLowerCase();
var parameter = RegExp.$2;
switch (command)
{
case 'ir.enable':
if(settingEnable)
{
}
else
{
settingEnable = true;
var Message = "Activation: enabled";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Activation: enabled");
}
return "";
case 'ir.disable':
if(settingEnable)
{
settingEnable = false;
var Message = "Activation: disabled";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Activation: disabled");
}
return "";
case 'ir.message':
return "";
case 'ir.timer':
return "";
case 'ir.pluson':
if(setMsgPlusAM)
{
}
else
{
setMsgPlusAM = true;
var Message = "Plus! Style: on";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Plus! Style: on");
}
return "";
case 'ir.plusoff':
if(setMsgPlusAM)
{
setMsgPlusAM = false;
var Message = "Plus! Style: off";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Plus! Style: off");
}
return "";
case 'ir.alerton':
if(setSignInAlert)
{
}
else
{
setSignInAlert = true;
var Message = "Sign-in Alert: enabled";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Sign-in Alert: on");
}
return "";
case 'ir.alertoff':
if(setSignInAlert)
{
setSignInAlert = false;
var Message = "Sign-in Alert: disabled";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Sign-in Alert: off");
}
return "";
case 'ir.status':
if (settingEnable)
{
var Message1 = "Message: " + settingMessage + "\nTimer: " + settingTimer + " milliseconds" + "\nPlus! Style: "
if (setMsgPlusAM) { var PMessage = "on" } else { var PMessage = "off" }
var Message2 = "\nSign-in Alert: "
if (setSignInAlert) { var SMessage = "on" } else { var SMessage = "off" }
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message1 + PMessage + Message2 + SMessage);
Debug.Trace("Instant Response | Message: " + settingMessage);
Debug.Trace("Instant Response | Timer: " + settingTimer + " milliseconds");
if (setMsgPlusAM) { Debug.Trace("Instant Response | Plus! Style: on"); }
else { Debug.Trace("Instant Response | Plus! Style: off"); }
if (setSignInAlert) { Debug.Trace("Instant Response | Sign-in Alert: on"); }
else { Debug.Trace("Instant Response | Sign-in Alert: off"); }
}
else
{
var Message = "Unable to show the status. You need to enable the script first!";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Status check error.");
}
return "";
default:
return 0;
}
}
}
What I need, for the message and timer, is that the user types in the command, followed by the message/timer, and the script will set it.
code:
Example: /ir.message Hello there. --> (sets message to "Hello there.")
Example: /ir.timer 1000 --> (sets timer to "1000")
How do I do this?
(edit: codes in JavaScript now)