XiFeng-blog
import itchat, requests, json
def get_response(msg):#应答程序
    url = \'http://www.tuling123.com/openapi/api/v2\'#图灵机器人接口地址
    send_msg = {#发送给图灵机器人的消息格式(json),参考api文档
        "reqType": 0,#文本格式
        "perception": {
            "inputText": {
                "text": msg    #发送的文本内容
            },
        },
        "userInfo": {
            "apiKey": " ",#机器人apiKey
            "userId": "363282"#标示用户
        }
    }
    try:
        r = requests.post(url, data = json.dumps(send_msg)).json()#把收到的微信消息发送给图灵机器人
        return r[\'results\'][0][\'values\'][\'text\']#返回图灵机器人说的消息,我的微信号只是个搬运工
    except:
        return
@itchat.msg_register(\'Text\')#定义消息类型为文本
def text_reply(msg):
        return  get_response(msg[\'Text\'])

itchat.auto_login(True)#扫码登入微信,和登入网页版微信一样
itchat.run()#自动应答

 

分类:

技术点:

相关文章:

  • 2021-10-24
  • 2022-01-12
  • 2019-09-12
  • 2021-11-11
  • 2021-12-04
  • 2021-05-25
  • 2021-06-24
  • 2021-06-24
猜你喜欢
  • 2021-12-05
  • 2021-11-30
  • 2021-12-12
  • 2021-11-02
  • 2021-12-14
  • 2021-12-14
相关资源
相似解决方案