-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitchat_respond_bot.py
More file actions
36 lines (28 loc) · 1.07 KB
/
itchat_respond_bot.py
File metadata and controls
36 lines (28 loc) · 1.07 KB
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
26
27
28
29
30
31
32
33
34
35
36
#coding=utf8
import itchat,time
from itchat.content import *
'''
##自动回复的功能
@itchat.msg_register(itchat.content.TEXT)
def text_reply(msg):
return msg['Text']
'''
@itchat.msg_register([TEXT,MAP,CARD,NOTE,SHARING])
def text_reply(msg):
itchat.send('%s: %s'%(msg['Type'],msg['Text']),msg['FromUserName'])
@itchat.msg_register([PICTURE,RECORDING,ATTACHMENT,VIDEO])
def download_files(msg):
msg['Text'](msg['FileName'])
return '@%s@%s'%({'Picture':'img','Video':'vid'}.get(msg['Type'],'fil'),msg['FileName'])
@itchat.msg_register(FRIENDS)
def add_friend(msg):
itchat.add_friend(**msg['Text'])# 该操作将自动将好友的消息录入,不需要重载通讯录
itchat.send_msg('Nice to meet you!',msg['RecommendInfo']['UserName'])
@itchat.msg_register(TEXT,isGroupChat=True)
def text_reply(msg):
if msg['isAt']:
itchat.send(u'@%s\u2005I received: %s '%(msg['ActualNickName'],msg['Content']),msg['FromUserName'])
itchat.auto_login(hotReload=True)
#向文件助手发送消息
itchat.send('Hello filehelper',toUserName='filehelper')
itchat.run()