From 552dc18b526a218a5c5b347416265904192f0a6f Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Thu, 23 Nov 2023 06:36:58 +0000 Subject: [PATCH] :recycle: change qq user id and group id field name --- nonebot/adapters/qq/bot.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/nonebot/adapters/qq/bot.py b/nonebot/adapters/qq/bot.py index 1368fe8..7662cb7 100644 --- a/nonebot/adapters/qq/bot.py +++ b/nonebot/adapters/qq/bot.py @@ -370,7 +370,7 @@ async def send_to_channel( async def send_to_c2c( self, - user_id: str, + openid: str, message: Union[str, Message, MessageSegment], msg_id: Optional[str] = None, msg_seq: Optional[int] = None, @@ -401,7 +401,7 @@ async def send_to_c2c( media: Optional[Media] = None if msg_type == 7: media_info = await self.post_c2c_files( - user_id=user_id, srv_send_msg=False, **self._extract_qq_media(message) + openid=openid, srv_send_msg=False, **self._extract_qq_media(message) ) media = ( Media(file_info=media_info.file_info) if media_info.file_info else None @@ -409,7 +409,7 @@ async def send_to_c2c( kwargs["media"] = media return await self.post_c2c_messages( - user_id=user_id, + openid=openid, msg_type=msg_type, msg_id=msg_id, msg_seq=msg_seq, @@ -419,7 +419,7 @@ async def send_to_c2c( async def send_to_group( self, - group_id: str, + group_openid: str, message: Union[str, Message, MessageSegment], msg_id: Optional[str] = None, msg_seq: Optional[int] = None, @@ -450,7 +450,9 @@ async def send_to_group( media: Optional[Media] = None if msg_type == 7: media_info = await self.post_group_files( - group_id=group_id, srv_send_msg=False, **self._extract_qq_media(message) + group_openid=group_openid, + srv_send_msg=False, + **self._extract_qq_media(message), ) media = ( Media(file_info=media_info.file_info) if media_info.file_info else None @@ -458,7 +460,7 @@ async def send_to_group( kwargs["media"] = media return await self.post_group_messages( - group_id=group_id, + group_openid=group_openid, msg_type=msg_type, msg_id=msg_id, msg_seq=msg_seq, @@ -490,7 +492,7 @@ async def send( elif isinstance(event, C2CMessageCreateEvent): event._reply_seq += 1 return await self.send_to_c2c( - user_id=event.author.id, + openid=event.author.id, message=message, msg_id=event.id, msg_seq=event._reply_seq, @@ -498,7 +500,7 @@ async def send( elif isinstance(event, GroupAtMessageCreateEvent): event._reply_seq += 1 return await self.send_to_group( - group_id=event.group_id, + group_openid=event.group_openid, message=message, msg_id=event.id, msg_seq=event._reply_seq, @@ -1606,7 +1608,7 @@ async def put_interaction( async def post_c2c_messages( self, *, - user_id: str, + openid: str, msg_type: Literal[0, 1, 2, 3, 4, 7], content: Optional[str] = None, markdown: Optional[MessageMarkdown] = None, @@ -1632,7 +1634,7 @@ async def post_c2c_messages( request = Request( "POST", - self.adapter.get_api_base().joinpath("v2", "users", user_id, "messages"), + self.adapter.get_api_base().joinpath("v2", "users", openid, "messages"), json=exclude_none( { "msg_type": msg_type, @@ -1669,7 +1671,7 @@ async def post_c2c_messages( async def post_c2c_files( self, *, - user_id: str, + openid: str, file_type: Literal[1, 2, 3, 4], url: str, srv_send_msg: bool = True, @@ -1677,7 +1679,7 @@ async def post_c2c_files( ) -> PostC2CFilesReturn: request = Request( "POST", - self.adapter.get_api_base().joinpath("v2", "users", user_id, "files"), + self.adapter.get_api_base().joinpath("v2", "users", openid, "files"), json=exclude_none( { "file_type": file_type, @@ -1694,7 +1696,7 @@ async def post_c2c_files( async def post_group_messages( self, *, - group_id: str, + group_openid: str, msg_type: Literal[0, 1, 2, 3, 4, 7], content: Optional[str] = None, markdown: Optional[MessageMarkdown] = None, @@ -1720,7 +1722,9 @@ async def post_group_messages( request = Request( "POST", - self.adapter.get_api_base().joinpath("v2", "groups", group_id, "messages"), + self.adapter.get_api_base().joinpath( + "v2", "groups", group_openid, "messages" + ), json=exclude_none( { "msg_type": msg_type, @@ -1757,7 +1761,7 @@ async def post_group_messages( async def post_group_files( self, *, - group_id: str, + group_openid: str, file_type: Literal[1, 2, 3, 4], url: str, srv_send_msg: bool = True, @@ -1765,7 +1769,7 @@ async def post_group_files( ) -> PostGroupFilesReturn: request = Request( "POST", - self.adapter.get_api_base().joinpath("v2", "groups", group_id, "files"), + self.adapter.get_api_base().joinpath("v2", "groups", group_openid, "files"), json=exclude_none( { "file_type": file_type,