cluic / wxauto

Windows版本微信客户端(非网页版)自动化,可实现简单的发送、接收微信消息,简单微信机器人
MIT License
2.4k stars 385 forks source link

GetNewMessage方法中是否需要判断newmsgs为空列表的情况 #240

Open boyer1231 opened 3 weeks ago

boyer1231 commented 3 weeks ago

python3.12.4 使用GetListenMessage()方法监听新消息出现如下错误 Traceback (most recent call last): File "C:\Users\jhb\wx_robot\pythonProject1\demo.py", line 21, in msgs = wx.GetListenMessage() ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jhb\wx_robot\pythonProject1.venv\Lib\site-packages\wxauto\wxauto.py", line 592, in GetListenMessage msg = chat.GetNewMessage(savepic=chat.savepic) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jhb\wx_robot\pythonProject1.venv\Lib\site-packages\wxauto\elements.py", line 339, in GetNewMessage if newmsgs[0].type == 'sys' and newmsgs[0].content == self._lang('查看更多消息'):


IndexError: list index out of range
在339后打印了一下发现是个空列表
加了一条判断后if len(newmsgs) > 0:能跑起来
Eaglezhou123 commented 6 days ago

大佬 len(newmsgs) > 0:能跑起来 这段加在哪里哈?