diff --git a/src/rdrama/services/CommentParser.ts b/src/rdrama/services/CommentParser.ts index ec9cec1..418f587 100644 --- a/src/rdrama/services/CommentParser.ts +++ b/src/rdrama/services/CommentParser.ts @@ -4,6 +4,7 @@ export class CommentParser { /** * Parses commands from the body of a single comment triggered by !!Oregon. * If the comment contains only "!!Oregon", it treats it as a "start" command. + * Additionally, if the command or any argument is a number, it is floored. * @param comment A single Comment object to be processed. * @returns An object containing the command and its arguments, if any. */ @@ -15,8 +16,15 @@ export class CommentParser { if (match) { // If the command is exactly "!!Oregon" with no additional command word, set command to "start" - const command = match[1] ? match[1].toLowerCase() : "start"; - const args = match[2] ? match[2].split(' ').map(arg => arg.trim()) : []; + let command = match[1] ? match[1].toLowerCase() : "start"; + const numCommand = Number(command); + if (!isNaN(numCommand) && isFinite(numCommand)) { + command = Math.floor(numCommand).toString(); + } + const args = match[2] ? match[2].split(' ').map(arg => { + const numArg = Number(arg); + return !isNaN(numArg) && isFinite(numArg) ? Math.floor(numArg).toString() : arg; + }) : []; return { command, args }; }