Skip to content

Commit e1c7716

Browse files
committed
fix discord @ message without '!'
1 parent b36303b commit e1c7716

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

kokkoro/bot/discord/discord_util.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def remove_mention_me(raw_message) -> (str, bool):
1212
return raw_message.replace(MENTION_BOT, "").strip(), True
1313
return raw_message, False
1414

15-
dc_at_pattern = r'<@![a-z0-9A-Z]+>'
15+
dc_at_pattern = r'<@!?[a-z0-9A-Z]+>'
1616
def normalize_message(raw_message: str) -> str:
1717
"""
1818
规范化 at 信息,"<@!123> waht<@!312>a12" => "@123 waht @312 a12"
@@ -26,4 +26,7 @@ def normalize_at(raw_at):
2626
"""
2727
规范化 at 信息,"<@!123>" => " @123 "
2828
"""
29-
return f' @{raw_at[3:-1]} '
29+
if '!' in raw_at:
30+
return f' @{raw_at[3:-1]} '
31+
else:
32+
return f' @{raw_at[2:-1]} '

0 commit comments

Comments
 (0)