update python_wechat.py

master
xianhu 2017-06-28 10:25:29 +08:00
parent f21f3d687f
commit 279da269fc
1 changed files with 6 additions and 11 deletions

View File

@ -24,7 +24,7 @@ my.auto_login(hotReload=False, enableCmdQR=-2)
# (4) chatroomList 群聊列表每一项为一个Chatroom字典类包括UserName, NickName, RemarkName, MemberCount, MemberList, Self等 # (4) chatroomList 群聊列表每一项为一个Chatroom字典类包括UserName, NickName, RemarkName, MemberCount, MemberList, Self等
# (5) mpList 订阅号列表每一项为一个MassivePlatform字典类包括UserName, NickName等 # (5) mpList 订阅号列表每一项为一个MassivePlatform字典类包括UserName, NickName等
my.global_keys = ["创业", "算法", "人工智能", "机器学习"] my.global_keys = ["创业", "人工智能", "企业服务"]
my.to_user_name = "filehelper" # 消息接受者 my.to_user_name = "filehelper" # 消息接受者
my.update_time = time.time() # 信息更新时间 my.update_time = time.time() # 信息更新时间
my.msg_store = {} # 消息存储队列 my.msg_store = {} # 消息存储队列
@ -105,11 +105,6 @@ def process_message_group(msg):
""" """
处理群消息 处理群消息
""" """
# 消息过滤, 只监测文字、图片、语音、名片、注解、分享等
if msg.we_type not in ["Text", "Picture", "Recording", "Card", "Note", "Sharing"]:
logging.warning("process_message_group: message type isn't included, ignored")
return
# ==== 处理红包消息 ==== # ==== 处理红包消息 ====
if msg.we_type == "Note" and msg.we_text.find("收到红包,请在手机上查看") >= 0: if msg.we_type == "Note" and msg.we_text.find("收到红包,请在手机上查看") >= 0:
my.send("%s】中有人发红包啦,快抢!" % msg.wind_name, toUserName=my.to_user_name) my.send("%s】中有人发红包啦,快抢!" % msg.wind_name, toUserName=my.to_user_name)
@ -132,11 +127,6 @@ def process_message_revoke(msg):
""" """
处理撤回消息 处理撤回消息
""" """
# 消息过滤, 只监测文字、图片、语音、名片、注解、分享等
if msg.we_type not in ["Text", "Picture", "Recording", "Card", "Note", "Sharing"]:
logging.warning("process_message_revoke: message type isn't included, ignored")
return
# 消息存储,删除过期消息 # 消息存储,删除过期消息
my.msg_store[msg.msg_id] = msg my.msg_store[msg.msg_id] = msg
for _id in [_id for _id in my.msg_store if time.time() - my.msg_store[_id].msg_time > 120]: 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):
# 消息提取 # 消息提取
msg = Message(msg) msg = Message(msg)
# 消息过滤, 只监测文字、图片、语音、名片、注解、分享等
if msg.we_type not in ["Text", "Picture", "Recording", "Card", "Note", "Sharing"]:
logging.warning("process_message_group: message type isn't included, ignored")
return
# 处理群消息 # 处理群消息
if msg.from_user_name.startswith("@@"): if msg.from_user_name.startswith("@@"):
process_message_group(msg) process_message_group(msg)