Commit c709ac6

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-09-02 16:21:54
fix(danmu): correct regex to parse username
1 parent 2455efb
Changed files (1)
src
src/danmu/entrypoint.py
@@ -156,7 +156,6 @@ def parse_queries(texts: str, qtype: str) -> tuple[str, str, str, str]:
     # 2025
     elif matched := re.match(rf"^{PREFIX.DANMU}" + r"\s+(\d{4})(\s+)?", texts):
         match_time = matched.group(1)
-
     # remove prefix + date
     texts = re.sub(rf"^{PREFIX.DANMU}\s+{match_time}", "", texts).lstrip()
     # @张三 你好
@@ -188,9 +187,9 @@ def parse_queries(texts: str, qtype: str) -> tuple[str, str, str, str]:
                 texts = re.sub(r"^‘(.*?)’", "", texts)
             else:
                 return "", "", "", "查询格式有误, 用户名右侧缺失中文单引号"
-        elif matched := re.match(r"^@(\w+)(\s+)?", texts):
+        elif matched := re.match(r"^(\w+)(\s+)?", texts):
             user = matched.group(1)
-            texts = re.sub(rf"^@{user}", "", texts)
+            texts = re.sub(rf"^{user}", "", texts)
 
     keyword = texts.lstrip()