TH_NUM的博客

日常积累

itchat微信自动回复消息

使用之前需要准备的工作:安装itchat API
easy_install itchat

#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()
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/TH_NUM/article/details/55657297
文章标签: 微信 api
个人分类: 微信itchat
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

itchat微信自动回复消息

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭