From d297b5616b4d3d379e6cd8789cd98e6472f179e5 Mon Sep 17 00:00:00 2001 From: lunarutku <101830604+lunarutku@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:06:12 +0300 Subject: [PATCH 1/4] Using shlex.split to split arguments --- rustplus/commands/command_handler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rustplus/commands/command_handler.py b/rustplus/commands/command_handler.py index 960f506..c5df6f3 100644 --- a/rustplus/commands/command_handler.py +++ b/rustplus/commands/command_handler.py @@ -1,4 +1,5 @@ import asyncio +import shlex from datetime import datetime from . import Command, CommandTime @@ -35,7 +36,7 @@ async def run_command(self, message: RustChatMessage, prefix) -> None: message.steam_id, CommandTime(datetime.utcfromtimestamp(message.time), message.time), command, - message.message.split(" ")[1:], + shlex.split(message.message), ) ) else: @@ -52,7 +53,7 @@ async def run_command(self, message: RustChatMessage, prefix) -> None: datetime.utcfromtimestamp(message.time), message.time ), command, - message.message.split(" ")[1:], + shlex.split(message.message), ), ) break From 657b14f803bd8a6a1cadfa123b45eeeb426223b0 Mon Sep 17 00:00:00 2001 From: lunarutku <101830604+lunarutku@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:07:05 +0300 Subject: [PATCH 2/4] Shlex 2 --- rustplus/commands/command_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustplus/commands/command_handler.py b/rustplus/commands/command_handler.py index c5df6f3..54ca3fa 100644 --- a/rustplus/commands/command_handler.py +++ b/rustplus/commands/command_handler.py @@ -23,7 +23,7 @@ def register_command(self, data: CommandData) -> None: async def run_command(self, message: RustChatMessage, prefix) -> None: if prefix == self.command_options.prefix: - command = message.message.split(" ")[0][len(prefix) :] + command = shlex.split(message.message)[0][len(prefix) :] else: command = prefix From f60c3f1846fe3f07abffc188d94002399760e56f Mon Sep 17 00:00:00 2001 From: lunarutku <101830604+lunarutku@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:07:24 +0300 Subject: [PATCH 3/4] add shlex to requirements --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index dc5cc2d..acf41be 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ http-ece requests numpy scipy -betterproto==2.0.0b6 \ No newline at end of file +betterproto==2.0.0b6 +shlex From d6290d4c82b698e24667f6f25b23ffee2d4a258a Mon Sep 17 00:00:00 2001 From: lunarutku <101830604+lunarutku@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:42:30 +0300 Subject: [PATCH 4/4] Fix slicing --- rustplus/commands/command_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rustplus/commands/command_handler.py b/rustplus/commands/command_handler.py index 54ca3fa..47d5107 100644 --- a/rustplus/commands/command_handler.py +++ b/rustplus/commands/command_handler.py @@ -36,7 +36,7 @@ async def run_command(self, message: RustChatMessage, prefix) -> None: message.steam_id, CommandTime(datetime.utcfromtimestamp(message.time), message.time), command, - shlex.split(message.message), + shlex.split(message.message)[1:], ) ) else: @@ -53,7 +53,7 @@ async def run_command(self, message: RustChatMessage, prefix) -> None: datetime.utcfromtimestamp(message.time), message.time ), command, - shlex.split(message.message), + shlex.split(message.message)[1:], ), ) break