tencent-connect / botpy

QQ频道机器人PythonSDK
MIT License
543 stars 86 forks source link

关于收到@信息后发送私聊信息错误 #113

Closed MaGua-Bishop closed 2 years ago

MaGua-Bishop commented 2 years ago

你好,我在使用python版sdk开发的时候遇到了一个错误无法解决 ` async def sendDms(self, message, **data): """发送私信""" await self.api.create_dms(guild_id=message.guild_id, user_id=message.author.id)

await self.api.post_dms(guild_id=message.guild_id, **data)

    await self.api.post_dms(guild_id=message.guild_id, content="123123",msg_id=message.id)`

写了一个方法专门用于来发送私聊信息,不知道哪儿出现了问题,返回报错为 File "C:/Users/16917/Desktop/qq/qqbot_django/QQ_bot/bot_main2.py", line 126, in sendDms await self.api.post_dms(guild_id=message.guild_id, content="123123",msg_id=message.id) File "C:\Users\16917\AppData\Local\Programs\Python\Python38\lib\site-packages\botpy\api.py", line 628, in post_dms return await self._http.request(route, json=payload) File "C:\Users\16917\AppData\Local\Programs\Python\Python38\lib\site-packages\botpy\http.py", line 121, in request return await _handle_response(route.url, response) File "C:\Users\16917\AppData\Local\Programs\Python\Python38\lib\site-packages\botpy\http.py", line 44, in _handle_response raise error_dict_get(msg=message) botpy.errors.ServerError: internal error: direct message error

GLGDLY commented 2 years ago

await self.api.create_dms(guild_id=message.guild_id, user_id=message.author.id)之后会返回一个私信频道的guild id,因此你await self.api.post_dms(guild_id=message.guild_id, **data)这里的guild id不应该是message.guild_id,而是创建私信时返回的私信频道id

SaucePlum commented 2 years ago

检查是否使用了正确的guild_id