|
16 | 16 | # 初始化
|
17 | 17 | my = itchat.new_instance()
|
18 | 18 | my.auto_login(hotReload=False, enableCmdQR=2)
|
19 |
| -my.global_keys = ["创业", "算法", "人工智能"] |
| 19 | +my.global_keys = ["创业", "算法", "人工智能", "机器学习"] |
20 | 20 | my.to_user_name = "filehelper"
|
21 | 21 |
|
22 | 22 | # my还包括的以下属性,注意用点.查看:
|
@@ -96,8 +96,8 @@ def text_reply(msg):
|
96 | 96 | msg_id, from_user_name, to_user_name, msg_type, msg_content, msg_time, \
|
97 | 97 | 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)
|
98 | 98 |
|
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"]: |
101 | 101 | logging.warning("message type isn't included, ignored")
|
102 | 102 | return
|
103 | 103 |
|
@@ -130,16 +130,15 @@ def text_reply(msg):
|
130 | 130 |
|
131 | 131 | if we_type == "Text":
|
132 | 132 | 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 |
141 | 133 | elif we_type == "Sharing":
|
142 | 134 | 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 |
143 | 142 |
|
144 | 143 | 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)
|
145 | 144 | return
|
|
0 commit comments