Itchat implemented using micro-channel automatic bot (included Robot API)

import itchat
import requests


def answer(content):
    url = 'http://api.chatbot.cn/cloud/robot/5aa28b810d00008b2baa8545/answer?channel=app&userId=5aa28b810d00008b2baa8545&sessionId=0&question='
    respon = requests.get(url+content).text
    answer = eval(respon)['answers'][0]['answer']
    return answer

@itchat.msg_register([itchat.content.TEXT],isFriendChat=True)
def question(msg):
    if msg['Type'] == 'Text':
        content = msg['Content']
        req = answer(content)
        itchat.send('[自动回复]\n'+req,msg['FromUserName'])


def login():
    print('微信已登录……')
def ex():
    print('微信已退出……')

itchat.auto_login(hotReload=True,loginCallback=login,exitCallback=ex)
itchat.run()

Many users said web micro-channel can not log, but bloggers have been able to log on, use the same itchat, I can still use, but for some time to log too often, the use of python logged in micro-channel will be forced off the assembly line, connecting WIFI hotspot login will When prompted log on to the exception, but the use of cable broadband Log will not be prompted to log anomaly report, posted here two seats on today's chart to explain the situation Login landlord Login may be newly registered micro signal is limited, you can try other little longer micro signal

Published 35 original articles · won praise 30 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43792401/article/details/101675627