2424# (4) chatroomList 群聊列表,每一项为一个Chatroom字典类,包括UserName, NickName, RemarkName, MemberCount, MemberList, Self等
2525# (5) mpList 订阅号列表,每一项为一个MassivePlatform字典类,包括UserName, NickName等
2626
27- my .global_keys = ["创业" , "算法" , " 人工智能" , "机器学习 " ]
27+ my .global_keys = ["创业" , "人工智能" , "企业服务 " ]
2828my .to_user_name = "filehelper" # 消息接受者
2929my .update_time = time .time () # 信息更新时间
3030my .msg_store = {} # 消息存储队列
@@ -105,11 +105,6 @@ def process_message_group(msg):
105105 """
106106 处理群消息
107107 """
108- # 消息过滤, 只监测文字、图片、语音、名片、注解、分享等
109- if msg .we_type not in ["Text" , "Picture" , "Recording" , "Card" , "Note" , "Sharing" ]:
110- logging .warning ("process_message_group: message type isn't included, ignored" )
111- return
112-
113108 # ==== 处理红包消息 ====
114109 if msg .we_type == "Note" and msg .we_text .find ("收到红包,请在手机上查看" ) >= 0 :
115110 my .send ("【%s】中有人发红包啦,快抢!" % msg .wind_name , toUserName = my .to_user_name )
@@ -132,11 +127,6 @@ def process_message_revoke(msg):
132127 """
133128 处理撤回消息
134129 """
135- # 消息过滤, 只监测文字、图片、语音、名片、注解、分享等
136- if msg .we_type not in ["Text" , "Picture" , "Recording" , "Card" , "Note" , "Sharing" ]:
137- logging .warning ("process_message_revoke: message type isn't included, ignored" )
138- return
139-
140130 # 消息存储,删除过期消息
141131 my .msg_store [msg .msg_id ] = msg
142132 for _id in [_id for _id in my .msg_store if time .time () - my .msg_store [_id ].msg_time > 120 ]:
@@ -187,6 +177,11 @@ def text_reply(msg):
187177 # 消息提取
188178 msg = Message (msg )
189179
180+ # 消息过滤, 只监测文字、图片、语音、名片、注解、分享等
181+ if msg .we_type not in ["Text" , "Picture" , "Recording" , "Card" , "Note" , "Sharing" ]:
182+ logging .warning ("process_message_group: message type isn't included, ignored" )
183+ return
184+
190185 # 处理群消息
191186 if msg .from_user_name .startswith ("@@" ):
192187 process_message_group (msg )
0 commit comments