wjaihui
#-*- coding:utf-8 -*-
import itchat
import requests

def get_response(msg):
    apiurl = \'http://i.itpk.cn/api.php\'  #//moli机器人的网址
    data={
        "question": msg,    #//获取到聊天的文本信息
        "api_key": "xxxxxxxxxxxxxxxx",
        #"api_secret": "n4gxkdyckd7p"
    }

    r=requests.post(apiurl,data=data)  #//构造网络请求
    return r.text
@itchat.msg_register(itchat.content.TEXT)     #//好友消息的处理
def print_content(msg):
    return get_response(msg[\'Text\'])
@itchat.msg_register([itchat.content.TEXT], isGroupChat=True)    #//群消息的处理
def print_content(msg):
    return get_response(msg[\'Text\'])
itchat.auto_login(True)           #//自动登录
itchat.run()                       #//启动聊天机器人

 

分类:

技术点:

相关文章:

  • 2021-04-22
  • 2021-11-20
  • 2021-05-27
  • 2022-02-18
  • 2021-11-03
  • 2021-10-28
  • 2022-01-22
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2021-09-30
  • 2021-11-17
  • 2022-12-23
  • 2021-09-05
  • 2021-07-12
相关资源
相似解决方案