Skip to content

Commit

Permalink
fix discord @ message without '!'
Browse files Browse the repository at this point in the history
  • Loading branch information
SonodaHanami committed Sep 4, 2020
1 parent b36303b commit e1c7716
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kokkoro/bot/discord/discord_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def remove_mention_me(raw_message) -> (str, bool):
return raw_message.replace(MENTION_BOT, "").strip(), True
return raw_message, False

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

0 comments on commit e1c7716

Please sign in to comment.