@@ -70,17 +70,21 @@ def _compose_context(self, ctype: ContextType, content, **kwargs):
7070 # 校验关键字
7171 match_prefix = check_prefix (content , conf ().get ('group_chat_prefix' ))
7272 match_contain = check_contain (content , conf ().get ('group_chat_keyword' ))
73+ flag = False
7374 if match_prefix is not None or match_contain is not None :
75+ flag = True
7476 if match_prefix :
7577 content = content .replace (match_prefix , '' , 1 ).strip ()
76- elif context ['msg' ].is_at and not conf ().get ("group_at_off" , False ):
77- logger .info ("[WX]receive group at, continue" )
78+ if context ['msg' ].is_at :
79+ logger .info ("[WX]receive group at" )
80+ if not conf ().get ("group_at_off" , False ):
81+ flag = True
7882 pattern = f'@{ self .name } (\u2005 |\u0020 )'
7983 content = re .sub (pattern , r'' , content )
80- elif context [ "origin_ctype" ] == ContextType . VOICE :
81- logger . info ( "[WX]receive group voice, checkprefix didn't match" )
82- return None
83- else :
84+
85+ if not flag :
86+ if context [ "origin_ctype" ] == ContextType . VOICE :
87+ logger . info ( "[WX]receive group voice, but checkprefix didn't match" )
8488 return None
8589 else : # 单聊
8690 match_prefix = check_prefix (content , conf ().get ('single_chat_prefix' ))
@@ -106,7 +110,6 @@ def _compose_context(self, ctype: ContextType, content, **kwargs):
106110
107111 return context
108112
109- # 处理消息 TODO: 如果wechaty解耦,此处逻辑可以放置到父类
110113 def _handle (self , context : Context ):
111114 if context is None or not context .content :
112115 return
0 commit comments