Skip to content

Commit f52730d

Browse files
committed
update wechat.py
1 parent 97954d7 commit f52730d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

python_wechat.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# 初始化
1717
my = itchat.new_instance()
1818
my.auto_login(hotReload=False, enableCmdQR=2)
19-
my.global_keys = ["创业", "算法", "人工智能"]
19+
my.global_keys = ["创业", "算法", "人工智能", "机器学习"]
2020
my.to_user_name = "filehelper"
2121

2222
# my还包括的以下属性,注意用点.查看:
@@ -96,8 +96,8 @@ def text_reply(msg):
9696
msg_id, from_user_name, to_user_name, msg_type, msg_content, msg_time, \
9797
msg_file, msg_file_length, msg_voice_length, msg_play_length, msg_url, wind_name, nick_name, we_type, we_text = get_msg_list(msg)
9898

99-
# 消息过滤, 只监测文字、注解、分享、图片、语音、视频、附件等
100-
if we_type not in ["Text", "Note", "Sharing", "Picture", "Recording", "Video", "Attachment"]:
99+
# 消息过滤, 只监测文字、注解、分享、图片、语音等
100+
if we_type not in ["Text", "Note", "Sharing", "Picture", "Recording"]:
101101
logging.warning("message type isn't included, ignored")
102102
return
103103

@@ -130,16 +130,15 @@ def text_reply(msg):
130130

131131
if we_type == "Text":
132132
msg_content = we_text
133-
elif we_type in ["Picture", "Recording", "Video", "Attachment"]:
134-
if (msg_file_length <= 500000) and (msg_voice_length <= 60000) and (msg_play_length <= 10):
135-
try:
136-
we_text(".Cache/" + msg_file)
137-
logging.warning("downloading %s to .Cache/", msg_file)
138-
except:
139-
logging.error("downloading %s to .Cache/ error", msg_file)
140-
msg_content = msg_file
141133
elif we_type == "Sharing":
142134
msg_content = we_text + ": " + msg_url
135+
elif we_type in ["Picture", "Recording"]:
136+
try:
137+
we_text(".Cache/" + msg_file)
138+
logging.warning("downloading %s to .Cache/", msg_file)
139+
except Exception as excep:
140+
logging.error("downloading %s to .Cache/ error: %s", msg_file, excep)
141+
msg_content = msg_file
143142

144143
my.send("【%s】中有消息被撤回:\nFrom: %s\nType: %s\nTime: %s\n%s" % (wind_name, nick_name, we_type, msg_time, msg_content), toUserName=my.to_user_name)
145144
return

0 commit comments

Comments
 (0)