源代码
import itchat
from itchat.content import TEXT, PICTURE, RECORDING
who_send=None
@itchat.msg_register(TEXT, isFriendChat=True)
def send_ice(msg):
global who_send
msg_text = msg['Text']
who_send = msg['FromUserName']
if who_send != GF:
itchat.send(msg_text, xiaoice)
@itchat.msg_register(PICTURE, isFriendChat=True)
def send_ice(msg):
global who_send
msg['Text'](msg['FileName'])
who_send = msg['FromUserName']
if who_send != GF:
itchat.send('@img@%s' % msg['FileName'], xiaoice)
@itchat.msg_register(RECORDING, isFriendChat=True)
def send_ice(msg):
global who_send
msg['Text'](msg['FileName'])
who_send = msg['FromUserName']
if who_send != GF:
itchat.send('@fil@%s' % msg['FileName'], xiaoice)
@itchat.msg_register(TEXT, isGroupChat=True)
def send_ice(msg):
global who_send
msg_text = msg['Text']
who_send = msg['FromUserName']
if who_send == qun_301:
itchat.send(msg_text, xiaoice)
@itchat.msg_register(PICTURE, isGroupChat=True)
def send_ice(msg):
global who_send
msg['Text'](msg['FileName'])
who_send = msg['FromUserName']
if who_send == qun_301:
itchat.send('@img@%s' % msg['FileName'], xiaoice)
@itchat.msg_register(TEXT, isMpChat=True)
def get_ice(msg):
if who_send != GF:
ice_msg = msg['Text']
itchat.send('微软小冰自动回复:' + ice_msg, who_send)
@itchat.msg_register(PICTURE, isMpChat=True)
def get_ice(msg):
if who_send != GF:
msg['Text'](msg['FileName'])
# ice_msg = msg['Text']
itchat.send('@img@%s' % msg['FileName'], who_send)
@itchat.msg_register(RECORDING, isMpChat=True)
def get_ice(msg):
if who_send != GF:
msg['Text'](msg['FileName'])
# ice_msg = msg['Text']
itchat.send('@fil@%s' % msg['FileName'], who_send)
itchat.auto_login()
xiaoice = itchat.search_mps(name='小冰')[0]['UserName']
GF = itchat.search_friends(name='Spring Day')[0]['UserName']
qun_301 = itchat.search_chatrooms(name='爸爸带你们上铂金')[0]['UserName']
itchat.run()