-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwxchat.py
More file actions
25 lines (20 loc) · 901 Bytes
/
wxchat.py
File metadata and controls
25 lines (20 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#coding=utf8
import itchat
# 自动回复
# 封装好的装饰器,当接收到的消息是Text,即文字消息
@itchat.msg_register('Text')
def text_reply(msg):
# 当消息不是由自己发出的时候
if not msg['FromUserName'] == myUserName:
# 发送一条提示给文件助手
itchat.send_msg(u"[%s]收到好友@%s 的信息:%s\n" %
(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(msg['CreateTime'])),
msg['User']['NickName'],
msg['Text']), 'filehelper')
# 回复给好友
return u'[自动回复]您好,我现在有事不在,一会再和您联系。\n已经收到您的的信息:%s\n' % (msg['Text'])
if __name__ == '__main__':
itchat.auto_login()
# 获取自己的UserName
myUserName = itchat.get_friends(update=True)[0]["UserName"]
itchat.run()