wechaty / python-wechaty-puppet-itchat

Python Wechaty Puppet Powered by Itchat
Apache License 2.0
39 stars 11 forks source link

当我发送文字 [泽@Home 9]:没问题,发#ding 时,异常退出了。 #14

Closed fangjiyuan closed 3 years ago

fangjiyuan commented 3 years ago

当我发送文字 [泽@Home 9]:没问题,发#ding 时,异常退出了。 Traceback (most recent call last): File "d:/github/python-wechaty-puppet-itchat/examples/ding-dong-bot.py", line 17, in asyncio.run(main()) File "D:\ProgramData\Anaconda3\envs\py37\lib\asyncio\runners.py", line 43, in run return loop.run_until_complete(main) File "D:\ProgramData\Anaconda3\envs\py37\lib\asyncio\base_events.py", line 587, in run_until_complete return future.result() File "d:/github/python-wechaty-puppet-itchat/examples/ding-dong-bot.py", line 16, in main await bot.start() File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty\wechaty.py", line 419, in start await self.puppet.start() File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty_puppet_itchat-ordereddictmajor.0_.minor.0_.patch.2_.prerelease.none_.build.none_-py3.7.egg\wechaty_puppet_itchat\puppet.py", line 913, in start File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty_puppet_itchat-ordereddictmajor.0_.minor.0_.patch.2_.prerelease.none_.build.none_-py3.7.egg\wechaty_puppet_itchat\puppet.py", line 1089, in _listen_for_event File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty_puppet_itchat-ordereddictmajor.0_.minor.0_.patch.2_.prerelease.none_.build.none_-py3.7.egg\wechaty_puppet_itchat\puppet.py", line 1086, in run File "D:\ProgramData\Anaconda3\envs\py37\lib\site-packages\wechaty_puppet_itchat-ordereddictmajor.0_.minor.0_.patch.2_.prerelease.none_.build.none_-py3.7.egg\wechaty_puppet_itchat\puppet.py", line 1078, in reply_fn File "d:/github/python-wechaty-puppet-itchat\src\itchat\components\register.py", line 48, in configured_reply message_container[msg['MsgId']] = msg File "d:/github/python-wechaty-puppet-itchat\src\itchat\storage\messagequeue.py", line 26, in getitem return super(Message, self).getitem(value) KeyError: 'MsgId'

lyleshaw commented 3 years ago

Thanks for your issue, I'll fix this bug in the next PR. If you want to use it now, you can replace src/itchat/components/register.py, line 46:

    try:
        msg = self.msgList.get(timeout=1)
        message_container[msg['MsgId']] = msg

with

    try:
        msg = self.msgList.get(timeout=1)
        if 'MsgId' in msg.keys():
            message_container[msg['MsgId']] = msg
zepengliu commented 3 years ago

yeah。after change the code what you show, it is ok now