🐛 fix(ChatProcess.py): add 'flags=re.UNICODE' to the re.sub() function to correctly handle non-ASCII characters in name

This commit is contained in:
2023-09-02 21:12:13 +02:00
parent f896001305
commit 1d2f5a3eed

View File

@@ -118,7 +118,7 @@ class Chat:
role = "user" role = "user"
name = msg.author.global_name name = msg.author.global_name
# use re not make name match ^[a-zA-Z0-9_-]{1,64}$ by removing all non-alphanumeric characters # 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) name = re.sub(r"[^a-zA-Z0-9_-]", "", name, flags=re.UNICODE)
if not await moderate(self.openai_api_key, msg.content): if not await moderate(self.openai_api_key, msg.content):
self.context.append( self.context.append(
{ {