tencent-connect / botpy

QQ频道机器人PythonSDK
MIT License
471 stars 79 forks source link

狗屁不通的错误提示 #178

Open CubicStone31 opened 3 months ago

CubicStone31 commented 3 months ago

使用api.get_channels时提示“频道末对机器人末授权”。请问究竟是需要授权还是不需要授权? 另外,即使在机器人权限中把所有权限都打开,还是会出现此错误。

示例报错如下 [ERROR] (http.py:76)_handle_response [botpy] 接口请求异常,请求连接: https://api.sgroup.qq.com/guilds/10290137413427843821/channels, 错误代码: 400, 返回内容: {'message': '频道末对机器人末授权', 'code': 11264, 'err_code': 40012009, 'trace_id': '51b47340e42f1bb52031c3c14cdbe5b3'}, trace_id:51b47340e42f1bb52031c3c14cdbe5b3 Traceback (most recent call last): File "/Users/cubicstone31/Desktop/Crypto/lib/python3.12/site-packages/botpy/client.py", line 285, in _run_event await coro(*args, **kwargs) File "/Users/cubicstone31/Desktop/Crypto/work/qqbot.py", line 26, in on_direct_message_create await self.api.get_channels(guild_id=message.guild_id) File "/Users/cubicstone31/Desktop/Crypto/lib/python3.12/site-packages/botpy/api.py", line 328, in get_channels return await self._http.request(route) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/cubicstone31/Desktop/Crypto/lib/python3.12/site-packages/botpy/http.py", line 190, in request return await _handle_response(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/cubicstone31/Desktop/Crypto/lib/python3.12/site-packages/botpy/http.py", line 85, in _handle_response raise ServerError(message) from None # adding from None to prevent chain exception being raised ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

触发问题的代码: class MyClient(botpy.Client): async def on_ready(self): _log.info(f"robot 「{self.robot.name}」 on_ready!")

async def on_direct_message_create(self, message: DirectMessage):
    # await self.api.post_dms(
    #     guild_id=message.guild_id,
    #     content=f"机器人{self.robot.name}收到你的私信了: {message.content}",
    #     msg_id=message.id,
    # )

    await self.api.get_channels(guild_id=message.guild_id)
chaunsin commented 4 weeks ago

使用api.get_channels时提示“频道末对机器人末授权”。请问究竟是需要授权还是不需要授权? 另外,即使在机器人权限中把所有权限都打开,还是会出现此错误。

示例报错如下 [ERROR] (http.py:76)_handle_response [botpy] 接口请求异常,请求连接: https://api.sgroup.qq.com/guilds/10290137413427843821/channels, 错误代码: 400, 返回内容: {'message': '频道末对机器人末授权', 'code': 11264, 'err_code': 40012009, 'trace_id': '51b47340e42f1bb52031c3c14cdbe5b3'}, trace_id:51b47340e42f1bb52031c3c14cdbe5b3 Traceback (most recent call last): File "/Users/cubicstone31/Desktop/Crypto/lib/python3.12/site-packages/botpy/client.py", line 285, in _run_event await coro(*args, **kwargs) File "/Users/cubicstone31/Desktop/Crypto/work/qqbot.py", line 26, in on_direct_message_create await self.api.get_channels(guild_id=message.guild_id) File "/Users/cubicstone31/Desktop/Crypto/lib/python3.12/site-packages/botpy/api.py", line 328, in get_channels return await self._http.request(route) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/cubicstone31/Desktop/Crypto/lib/python3.12/site-packages/botpy/http.py", line 190, in request return await _handle_response(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/cubicstone31/Desktop/Crypto/lib/python3.12/site-packages/botpy/http.py", line 85, in _handle_response raise ServerError(message) from None # adding from None to prevent chain exception being raised ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

触发问题的代码: class MyClient(botpy.Client): async def on_ready(self): _log.info(f"robot 「{self.robot.name}」 on_ready!")

async def on_direct_message_create(self, message: DirectMessage):
    # await self.api.post_dms(
    #     guild_id=message.guild_id,
    #     content=f"机器人{self.robot.name}收到你的私信了: {message.content}",
    #     msg_id=message.id,
    # )

    await self.api.get_channels(guild_id=message.guild_id)

我使用golang sdk也碰到了这个问题,也很是困惑