用python的itchat库做微信智能回复

版本:py3

调用图灵智能的智能服务;


#coding=utf8
import requests
import itchat

KEY = 'd013d2a0c5564918b1270855582d5d4f'

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']
    reply = get_response(msg['Text'])
    return reply or defaultReply

itchat.auto_login(hotReload=True)
itchat.run()

你可能感兴趣的:(奇淫技巧)