mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-20 13:47:15 +08:00
Merge pull request #2267 from 6vision/master
Optimize the welcome message for new members.
This commit is contained in:
@@ -14,9 +14,10 @@ class WechatMessage(ChatMessage):
|
|||||||
self.create_time = itchat_msg["CreateTime"]
|
self.create_time = itchat_msg["CreateTime"]
|
||||||
self.is_group = is_group
|
self.is_group = is_group
|
||||||
|
|
||||||
notes_join_group = ["加入群聊","加入了群聊","invited","joined"] # 可通过添加对应语言的加入群聊通知中的关键词适配更多
|
notes_join_group = ["加入群聊", "加入了群聊", "invited", "joined"] # 可通过添加对应语言的加入群聊通知中的关键词适配更多
|
||||||
notes_exit_group = ["移出了群聊","removed"] # 可通过添加对应语言的踢出群聊通知中的关键词适配更多
|
notes_bot_join_group = ["邀请你", "invited you", "You've joined", "你通过扫描"]
|
||||||
notes_patpat = ["拍了拍我","tickled my","tickled me"] # 可通过添加对应语言的拍一拍通知中的关键词适配更多
|
notes_exit_group = ["移出了群聊", "removed"] # 可通过添加对应语言的踢出群聊通知中的关键词适配更多
|
||||||
|
notes_patpat = ["拍了拍我", "tickled my", "tickled me"] # 可通过添加对应语言的拍一拍通知中的关键词适配更多
|
||||||
|
|
||||||
if itchat_msg["Type"] == TEXT:
|
if itchat_msg["Type"] == TEXT:
|
||||||
self.ctype = ContextType.TEXT
|
self.ctype = ContextType.TEXT
|
||||||
@@ -30,7 +31,11 @@ class WechatMessage(ChatMessage):
|
|||||||
self.content = TmpDir().path() + itchat_msg["FileName"] # content直接存临时目录路径
|
self.content = TmpDir().path() + itchat_msg["FileName"] # content直接存临时目录路径
|
||||||
self._prepare_fn = lambda: itchat_msg.download(self.content)
|
self._prepare_fn = lambda: itchat_msg.download(self.content)
|
||||||
elif itchat_msg["Type"] == NOTE and itchat_msg["MsgType"] == 10000:
|
elif itchat_msg["Type"] == NOTE and itchat_msg["MsgType"] == 10000:
|
||||||
if is_group and (any(note_join_group in itchat_msg["Content"] for note_join_group in notes_join_group)): # 若有任何在notes_join_group列表中的字符串出现在NOTE中
|
if is_group:
|
||||||
|
if any(note_bot_join_group in itchat_msg["Content"] for note_bot_join_group in notes_bot_join_group): # 邀请机器人加入群聊
|
||||||
|
logger.warn("机器人加入群聊消息,不处理~")
|
||||||
|
pass
|
||||||
|
elif any(note_join_group in itchat_msg["Content"] for note_join_group in notes_join_group): # 若有任何在notes_join_group列表中的字符串出现在NOTE中
|
||||||
# 这里只能得到nickname, actual_user_id还是机器人的id
|
# 这里只能得到nickname, actual_user_id还是机器人的id
|
||||||
if "加入群聊" not in itchat_msg["Content"]:
|
if "加入群聊" not in itchat_msg["Content"]:
|
||||||
self.ctype = ContextType.JOIN_GROUP
|
self.ctype = ContextType.JOIN_GROUP
|
||||||
@@ -46,7 +51,7 @@ class WechatMessage(ChatMessage):
|
|||||||
self.content = itchat_msg["Content"]
|
self.content = itchat_msg["Content"]
|
||||||
self.actual_user_nickname = re.findall(r"\"(.*?)\"", itchat_msg["Content"])[0]
|
self.actual_user_nickname = re.findall(r"\"(.*?)\"", itchat_msg["Content"])[0]
|
||||||
|
|
||||||
elif is_group and (any(note_exit_group in itchat_msg["Content"] for note_exit_group in notes_exit_group)): # 若有任何在notes_exit_group列表中的字符串出现在NOTE中
|
elif any(note_exit_group in itchat_msg["Content"] for note_exit_group in notes_exit_group): # 若有任何在notes_exit_group列表中的字符串出现在NOTE中
|
||||||
self.ctype = ContextType.EXIT_GROUP
|
self.ctype = ContextType.EXIT_GROUP
|
||||||
self.content = itchat_msg["Content"]
|
self.content = itchat_msg["Content"]
|
||||||
self.actual_user_nickname = re.findall(r"\"(.*?)\"", itchat_msg["Content"])[0]
|
self.actual_user_nickname = re.findall(r"\"(.*?)\"", itchat_msg["Content"])[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user