Add opt-in for rawQuotes in SlashCommand registration Closes #2739 Supersedes #2921

533aeffa369ef4f61b961323c7578a13c6440d38

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +10 -3Ignore whitespace
public/scripts/slash-commands.js+5 -0
@@ -227,6 +227,7 @@ export function initDefaultSlashCommands() {
227227 }));
228228 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
229229 name: 'sendas',
230+ rawQuotes: true,
230231 callback: sendMessageAs,
231232 returns: 'Optionally the text of the sent message, if specified in the "return" argument',
232233 namedArgumentList: [
@@ -293,6 +294,7 @@ export function initDefaultSlashCommands() {
293294 }));
294295 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
295296 name: 'sys',
297+ rawQuotes: true,
296298 callback: sendNarratorMessage,
297299 aliases: ['nar'],
298300 returns: 'Optionally the text of the sent message, if specified in the "return" argument',
@@ -357,6 +359,7 @@ export function initDefaultSlashCommands() {
357359 }));
358360 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
359361 name: 'comment',
362+ rawQuotes: true,
360363 callback: sendCommentMessage,
361364 returns: 'Optionally the text of the sent message, if specified in the "return" argument',
362365 namedArgumentList: [
@@ -574,6 +577,7 @@ export function initDefaultSlashCommands() {
574577 }));
575578 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
576579 name: 'send',
580+ rawQuotes: true,
577581 callback: sendUserMessageCallback,
578582 returns: 'Optionally the text of the sent message, if specified in the "return" argument',
579583 namedArgumentList: [
@@ -936,6 +940,7 @@ export function initDefaultSlashCommands() {
936940 }));
937941 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
938942 name: 'echo',
943+ rawQuotes: true,
939944 callback: echoCallback,
940945 returns: 'the text',
941946 namedArgumentList: [
public/scripts/slash-commands/SlashCommand.js+2 -0
@@ -36,6 +36,7 @@ export class SlashCommand {
3636 * @param {string} [props.helpString]
3737 * @param {boolean} [props.splitUnnamedArgument]
3838 * @param {Number} [props.splitUnnamedArgumentCount]
39+ * @param {boolean} [props.rawQuotes]
3940 * @param {string[]} [props.aliases]
4041 * @param {string} [props.returns]
4142 * @param {SlashCommandNamedArgument[]} [props.namedArgumentList]
@@ -54,6 +55,7 @@ export class SlashCommand {
5455 /**@type {string}*/ helpString;
5556 /**@type {boolean}*/ splitUnnamedArgument = false;
5657 /**@type {Number}*/ splitUnnamedArgumentCount;
58+ /** @type {boolean} */ rawQuotes = false;
5759 /**@type {string[]}*/ aliases = [];
5860 /**@type {string}*/ returns;
5961 /**@type {SlashCommandNamedArgument[]}*/ namedArgumentList = [];
public/scripts/slash-commands/SlashCommandParser.js+3 -3
@@ -975,7 +975,7 @@ export class SlashCommandParser {
975975 cmd.startUnnamedArgs = this.index - (/\s(\s*)$/s.exec(this.behind)?.[1]?.length ?? 0);
976976 cmd.endUnnamedArgs = this.index;
977977 if (this.testUnnamedArgument()) {
978978 cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument, cmd?.command?.splitUnnamedArgumentCount, cmd?.command?.rawQuotes);
979979 cmd.endUnnamedArgs = this.index;
980980 if (cmd.name == 'let') {
981981 const keyArg = cmd.namedArgumentList.find(it=>it.name == 'key');
@@ -1035,7 +1035,7 @@ export class SlashCommandParser {
10351035 testUnnamedArgumentEnd() {
10361036 return this.testCommandEnd();
10371037 }
10381038 parseUnnamedArgument(split, splitCount = null, rawQuotes = false) {
10391039 const wasSplit = split;
10401040 /**@type {SlashCommandClosure|String}*/
10411041 let value = this.jumpedEscapeSequence ? this.take() : ''; // take the first, already tested, char if it is an escaped one
@@ -1045,7 +1045,7 @@ export class SlashCommandParser {
10451045 /**@type {SlashCommandUnnamedArgumentAssignment}*/
10461046 let assignment = new SlashCommandUnnamedArgumentAssignment();
10471047 assignment.start = this.index;
10481048 if (!split && !rawQuotes && this.testQuotedValue()) {
10491049 // if the next bit is a quoted value, take the whole value and gather contents as a list
10501050 assignment.value = this.parseQuotedValue();
10511051 assignment.end = this.index;