From 20b4a1d42169f664365c40d06f33e2716b6e1be3 Mon Sep 17 00:00:00 2001 From: lunarutku <101830604+lunarutku@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:08:33 +0300 Subject: [PATCH] Using shlex.split instead of pythons own split. (#63) --- requirements.txt | 3 ++- rustplus/commands/command_handler.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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 diff --git a/rustplus/commands/command_handler.py b/rustplus/commands/command_handler.py index 960f506..47d5107 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 @@ -22,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 @@ -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)[1:], ) ) 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)[1:], ), ) break