微信 聊天 机器人 python itchat

版权声明:虽然是个蒟蒻但是转载还是要说一声的哟 https://blog.csdn.net/jpwang8/article/details/54810147

正文


调用itchat访问图灵机器人api聊天的小程序,应付一下过年的刷屏群发
之前搞的alice只能回英语,而且略呆傻
图灵api的key去注册账号就有了,网址戳这里
就是这样

Code


# -*- coding: utf-8 -*-
import requests, json
import itchat, aiml, os
from itchat.content import *

@itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING])
def text_reply(msg):
    # cont = alice.respond(msg['Text'])
    cont = requests.get('http://www.tuling123.com/openapi/api?key=就不告诉你&info=%s' % msg['Content']).content
    m = json.loads(cont)
    itchat.send(m['text'], msg['FromUserName'])
    if m['code'] == 200000:
        itchat.send(m['url'], msg['FromUserName'])
    if m['code'] == 302000:
        itchat.send(m['list'], msg['FromUserName'])
    if m['code'] == 308000:
        itchat.send(m['list'], msg['FromUserName'])

itchat.auto_login(hotReload = True)
itchat.run()
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页