python3 开发微信自动回复

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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)

python3 开发微信自动回复_第1张图片

转载于:https://my.oschina.net/michaelshu/blog/1623980

你可能感兴趣的:(python3 开发微信自动回复)