ItChat
ItChat copied to clipboard
报KeyError: 'Self'的错误
运行下面的代码登录后,控制台间歇性报出错误 代码:
#coding=utf8
import itchat, time
from itchat.content import *
f=open('msg.log', 'a')
@itchat.msg_register(INCOME_MSG)
def text_reply(msg):
print(msg['Type'])
f.write(msg['Type'] +":" + str(msg) + "\n")
f.flush()
itchat.auto_login(True)
itchat.run()
错误:
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\itchat\components\login.py", line 240, inmaintain_loop
msgList = produce_msg(self, msgList)
File "c:\Python27\lib\site-packages\itchat\components\messages.py", line 61, in produce_msg
produce_group_chat(core, m)
File "c:\Python27\lib\site-packages\itchat\components\messages.py", line 250,in produce_group_chat
atFlag = '@' + chatroom['Self'].get('DisplayName', core.storageClass.nickName)
KeyError: 'Self'
同样碰到这个问题:
2017-03-28 11:59:48,442: itchat [ERROR]
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/itchat/components/login.py", line 240, in maintain_loop
msgList = produce_msg(self, msgList)
File "/usr/local/lib/python3.5/dist-packages/itchat/components/messages.py", line 61, in produce_msg
produce_group_chat(core, m)
File "/usr/local/lib/python3.5/dist-packages/itchat/components/messages.py", line 250, in produce_group_chat
atFlag = '@' + chatroom['Self'].get('DisplayName', core.storageClass.nickName)
KeyError: 'Self'
已知问题,请等待更新
@zaghost @DrayChou @tempdban 已在新版本中修复该问题,请尝试1.3.3中是否仍存在报错。
pip install itchat -U