offu / WeRoBot

WeRoBot 是一个微信公众号开发框架

Home Page:https://werobot.readthedocs.io/zh_CN/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

被动回复消息,回复多个图片消息会重复发送同一张图片

SMU-Rainflow opened this issue · comments

我的代码:
image

日志如下:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/socketserver.py", line 320, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/local/lib/python3.6/socketserver.py", line 351, in process_request
self.finish_request(request, client_address)
File "/usr/local/lib/python3.6/socketserver.py", line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python3.6/socketserver.py", line 724, in init
self.handle()
File "/usr/local/lib/python3.6/wsgiref/simple_server.py", line 133, in handle
handler.run(self.server.get_app())
File "/usr/local/lib/python3.6/wsgiref/handlers.py", line 144, in run
self.close()
File "/usr/local/lib/python3.6/wsgiref/simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

解决方案:
把回复图片的逻辑放在子线程中执行,然后先回复给微信服务器一个空串。
问题原因:
微信服务器重发了用户的消息。
不理解的地方:
在5s内回复图片消息之后,好像还要回复一个空串才行,不然微信还是会重发

solved