nonebot / aiocqhttp

A Python SDK with async I/O for CQHTTP (OneBot).
https://aiocqhttp.nonebot.dev
MIT License
280 stars 39 forks source link

emmmmmm,加群(group_increase)消息发送失败 #9

Closed 892768447 closed 6 years ago

892768447 commented 6 years ago
@bot.on_notice('group_increase')
async def handle_group_increase(context):
    await bot.send(context, message='欢迎新人~', is_raw=True)

#ERROR:
await bot.send(context, message='欢迎新人~', is_raw=True)
  File "/usr/local/lib/python3.6/site-packages/aiocqhttp/__init__.py", line 206, in send
    return await self.send_msg(**context)
  File "/usr/local/lib/python3.6/site-packages/aiocqhttp/api.py", line 170, in call_action
    action, **params)
  File "/usr/local/lib/python3.6/site-packages/aiocqhttp/api.py", line 140, in call_action
    return _handle_api_result(await ResultStore.fetch(seq))
  File "/usr/local/lib/python3.6/site-packages/aiocqhttp/api.py", line 39, in _handle_api_result
    raise ActionFailed(retcode=result.get('retcode'))
aiocqhttp.exceptions.ActionFailed
stdrc commented 6 years ago

可以 try catch 一下看看那个 exception 的 retcode 是多少,另外,你发了我才发现 README 里的示例写错了,现在已经是 auto_escape 而不是 is_raw 了,但你这个应该不是因为这个原因

892768447 commented 6 years ago

嗯。我也看到文档了auto_escape。 下面是api.py 里 def _handle_api_result(result: Optional[Dict[str, Any]]) -> Any:

result的值: {'data': None, 'echo': {'seq': 1}, 'retcode': 100, 'status': 'failed'}

stdrc commented 6 years ago

我晚上看下,确实有可能是我代码的问题

892768447 commented 6 years ago
100 参数缺失或参数无效,通常是因为没有传入必要参数,某些接口中也可能因为参数明显无效(比如传入的 QQ 号小于等于 0,此时无需调用酷 Q 函数即可确定失败),此项和以下的 status 均为 failed
stdrc commented 6 years ago

确实是我的过,马上发个新版修掉