python3 开发微信自动回复

2018-02-27 11:22:28来源:oschina作者:MichaelShu人点击

分享

python3 做微信自动回复:


参考:


http://itchat.readthedocs.io/zh/latest/tutorial/tutorial0/

下载itchat:


https://pypi.python.org/pypi/itchat/


import itchat, time
from itchat.content import *
@itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING])
def text_reply(msg):
msg.user.send('%s: %s' % (msg.type, msg.text))
@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])
def download_files(msg):
msg.download(msg.fileName)
typeSymbol = {
PICTURE: 'img',
VIDEO: 'vid', }.get(msg.type, 'fil')
return '@%s@%s' % (typeSymbol, msg.fileName)
@itchat.msg_register(FRIENDS)
def add_friend(msg):
msg.user.verify()
msg.user.send('Nice to meet you!')
@itchat.msg_register(TEXT, isGroupChat=True)
def text_reply(msg):
if msg.isAt:
msg.user.send(u'@%s/u2005I received: %s' % (
msg.actualNickName, msg.text))
itchat.auto_login(True)
itchat.run(True)

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台