首先到图灵官网注册账号:http://www.tuling123.com/
稍后会用到你申请机器人的key
测试用的Python版本为3.5
安装itchat
pip install itchat
#coding=utf8
import requests
import itchat
#d5d1200c30f043e5abb14d3fbe9a2659
#8edce3ce905a4c1dbb965e6b35c3834d
KEY = 'd5d1200c30f043e5abb14d3fbe9a2659'
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: &#