feat: add support for PATPAT context

This commit is contained in:
lanvent
2023-04-18 23:34:08 +08:00
parent 0be56e5b25
commit de33911460
4 changed files with 32 additions and 8 deletions

View File

@@ -31,7 +31,6 @@ class WeChatMessage(ChatMessage):
"加入群聊" in itchat_msg["Content"] or "加入了群聊" in itchat_msg["Content"]
):
self.ctype = ContextType.JOIN_GROUP
logger.debug("[WX]join group message: " + itchat_msg["Content"])
self.content = itchat_msg["Content"]
# 这里只能得到nickname actual_user_id还是机器人的id
if "加入了群聊" in itchat_msg["Content"]:
@@ -42,6 +41,13 @@ class WeChatMessage(ChatMessage):
self.actual_user_nickname = re.findall(
r"\"(.*?)\"", itchat_msg["Content"]
)[0]
elif "拍了拍我" in itchat_msg["Content"]:
self.ctype = ContextType.PATPAT
self.content = itchat_msg["Content"]
if is_group:
self.actual_user_nickname = re.findall(
r"\"(.*?)\"", itchat_msg["Content"]
)[0]
else:
raise NotImplementedError(
"Unsupported note message: " + itchat_msg["Content"]
@@ -82,5 +88,5 @@ class WeChatMessage(ChatMessage):
if self.is_group:
self.is_at = itchat_msg["IsAt"]
self.actual_user_id = itchat_msg["ActualUserName"]
if self.ctype != ContextType.JOIN_GROUP:
if self.ctype not in [ContextType.JOIN_GROUP, ContextType.PATPAT]:
self.actual_user_nickname = itchat_msg["ActualNickName"]