ItChat icon indicating copy to clipboard operation
ItChat copied to clipboard

报KeyError: 'Self'的错误

Open zaghost opened this issue 9 years ago • 3 comments

运行下面的代码登录后,控制台间歇性报出错误 代码:

#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'

zaghost avatar Mar 27 '17 11:03 zaghost

同样碰到这个问题:

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'

DrayChou avatar Mar 28 '17 12:03 DrayChou

已知问题,请等待更新

tempdban avatar Mar 28 '17 23:03 tempdban

@zaghost @DrayChou @tempdban 已在新版本中修复该问题,请尝试1.3.3中是否仍存在报错。

pip install itchat -U

littlecodersh avatar Mar 29 '17 02:03 littlecodersh