From 119d791820cf5e29de4296b6437872eb7606ddef Mon Sep 17 00:00:00 2001 From: Paillat Date: Wed, 23 Aug 2023 15:22:15 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(ChatProcess.py):=20use=20r?= =?UTF-8?q?egular=20expression=20to=20remove=20non-alphanumeric=20characte?= =?UTF-8?q?rs=20from=20name=20to=20ensure=20it=20matches=20the=20required?= =?UTF-8?q?=20pattern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ChatProcess.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ChatProcess.py b/src/ChatProcess.py index 681b7c1..6b8ef93 100644 --- a/src/ChatProcess.py +++ b/src/ChatProcess.py @@ -117,6 +117,8 @@ 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) if not await moderate(self.openai_api_key, msg.content): self.context.append( {