当前位置:   article > 正文

python 微信自动回复_python 怎么连接微信自动回复

python 怎么连接微信自动回复

import requests
import itchat
import random

KEY = 'e4ac50ac3556477088af279fabae6982'

def get_response(msg):
    apiUrl = 'http://www.tuling123.com/openapi/api'
    data = {
        'key'    : KEY,
        'info'   : msg,
        'userid' : 'wechat-robot',
    }
    try:
        r = requests.post(apiUrl, data=data).json()
        return r.get('text')
    except:
        return

@itchat.msg_register(itchat.content.TEXT)
def tuling_reply(msg):
    defaultReply = 'I received: ' + msg['Text']
    robots=['——By Black','——By Youyou']
    reply = get_response(msg['Text'])
    return reply or defaultReply

itchat.auto_login(enableCmdQR=2)
itchat.run()

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号