wechaty / python-wechaty

Python Wechaty is a Conversational RPA SDK for Chatbot Makers written in Python
https://wechaty.readthedocs.io/zh_CN/latest/
Apache License 2.0
1.55k stars 229 forks source link

[Bug]: `msg.say('xxx')`调用后会伴随异常 #388

Open zhegexiaohuozi opened 1 year ago

zhegexiaohuozi commented 1 year ago

Environment

- wechaty                0.10.7
- wechaty-grpc           0.20.19
- wechaty-puppet         0.4.23
- wechaty-puppet-service 0.8.10
- wechaty-plugin-contrib: 
- token type: wxwork
- the version of wechaty docker container: [0.65]

Description

await msg.say('dong')  

调用后消息能发送成功,但是会伴随一个异常

Exception in callback AsyncIOEventEmitter._emit_run.<locals>.callback(<Task finishe...ut of range')>) at /usr/local/lib/python3.9/site-packages/pyee/asyncio.py:65
handle: <Handle AsyncIOEventEmitter._emit_run.<locals>.callback(<Task finishe...ut of range')>) at /usr/local/lib/python3.9/site-packages/pyee/asyncio.py:65>
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.9/site-packages/pyee/asyncio.py", line 71, in callback
    self.emit("error", exc)
  File "/usr/local/lib/python3.9/site-packages/wechaty/wechaty.py", line 332, in emit
    return super().emit(event, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pyee/base.py", line 179, in emit
    self._emit_handle_potential_error(event, args[0] if args else None)
  File "/usr/local/lib/python3.9/site-packages/pyee/base.py", line 139, in _emit_handle_potential_error
    raise error
  File "/Users/xx/work/code/py/python-wechaty-getting-started/examples/ding-dong-bot.py", line 102, in on_message
    await msg.say(qr_code)
  File "/usr/local/lib/python3.9/site-packages/wechaty/user/message.py", line 187, in say
    await message.ready()
  File "/usr/local/lib/python3.9/site-packages/wechaty/user/message.py", line 533, in ready
    self.payload = await self.puppet.message_payload(self.message_id)
  File "/usr/local/lib/python3.9/site-packages/wechaty_puppet_service/puppet.py", line 434, in message_payload
    return _map_message_type(response)
  File "/usr/local/lib/python3.9/site-packages/wechaty_puppet_service/puppet.py", line 159, in _map_message_type
    message_payload.type = map_container[message_payload.type]
IndexError: list index out of range

Minimum reproducible code

async def on_message(msg: Message):
    if msg.text() == 'ding':
          await msg.say('dong')