From e264d5f6541af30f417a3df08f2a77538664c1bc Mon Sep 17 00:00:00 2001 From: Paillat Date: Sat, 2 Sep 2023 21:14:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ChatProcess.py):=20handle=20?= =?UTF-8?q?empty=20name=20by=20falling=20back=20to=20msg.author.name=20to?= =?UTF-8?q?=20prevent=20empty=20names=20in=20the=20chat=20=F0=9F=94=A7=20c?= =?UTF-8?q?hore(ChatProcess.py):=20improve=20regex=20pattern=20to=20remove?= =?UTF-8?q?=20non-alphanumeric=20characters=20from=20name=20to=20match=20^?= =?UTF-8?q?[a-zA-Z0-9=5F-]{1,64}$=20pattern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ChatProcess.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ChatProcess.py b/src/ChatProcess.py index 65e4736..fb748ea 100644 --- a/src/ChatProcess.py +++ b/src/ChatProcess.py @@ -117,8 +117,10 @@ class Chat: else: role = "user" name = msg.author.global_name - # use re not make name match ^[a-zA-Z0-9_-]{1,64}$ by removing all non-alphanumeric characters - name = re.sub(r"[^a-zA-Z0-9_-]", "", name, flags=re.UNICODE) + # use re not make name match ^[a-zA-Z0-9_-]{1,64}$ by removing all non-alphanumeric characters + name = re.sub(r"[^a-zA-Z0-9_-]", "", name, flags=re.UNICODE) + if name == "": + name = msg.author.name if not await moderate(self.openai_api_key, msg.content): self.context.append( {