import itchat from bot import test from datetime import datetime now = str(datetime.now()) @itchat.msg_register(itchat.content.TEXT) def text_reply(msg): with open('wechat.log','a',encoding='utf-8') as f: fromuser = msg.FromUserName touser = msg.ToUserName text = msg.Text f.write(now+'\n') f.write(fromuser+'\n') f.write(text+'\n') f.write('\n') r = test(text) itchat.send(r, toUserName=fromuser) itchat.auto_login( hotReload=True) itchat.run()