利用图灵机器人实现自动聊天机器人

# -*- coding: utf-8 -*-

import itchat
import requests
#获取来自机器人API的回复消息
def get_response(msg):
	apiUrl='http://www.tuling123.com/openapi/api'
	data={'key':'08ee2d65b6d94dd2808c71583787f779',
		'info':msg,
		'userid':'世纪美女'}
	r=requests.post(apiUrl,data=data).json()
	return r.get("text")
	
#用于接收来自朋友的对话消息
@itchat.msg_register(itchat.content.TEXT)
def print_content(msg):
	return get_response(msg['Text'])
	
itchat.auto_login()
itchat.run()

猜你喜欢

转载自blog.csdn.net/qq_22764567/article/details/86567933