From a5ed21ec192e470ba3ecbe905dce016e547fe9f7 Mon Sep 17 00:00:00 2001 From: RexQian Date: Mon, 16 Sep 2024 15:13:38 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E5=8F=91=E9=80=81=E6=9C=AC=E5=9C=B0base64=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/botpy/api.py b/botpy/api.py index c1c5b50..09e9e31 100644 --- a/botpy/api.py +++ b/botpy/api.py @@ -1475,6 +1475,7 @@ async def post_group_file( file_type: int, url: str, srv_send_msg: bool = False, + file_data: str = None, ) -> message.Media: """ 上传/发送群聊图片 @@ -1484,6 +1485,7 @@ async def post_group_file( file_type (int): 媒体类型:1 图片png/jpg,2 视频mp4,3 语音silk,4 文件(暂不开放) url (str): 需要发送媒体资源的url srv_send_msg (bool): 设置 true 会直接发送消息到目标端,且会占用主动消息频次 + file_data (str): 要发送的本地图像的Base64数据 """ payload = locals() payload.pop("self", None) From 965c15105a44be446e5a48a2aef014209b14d170 Mon Sep 17 00:00:00 2001 From: RexQian Date: Mon, 16 Sep 2024 15:20:04 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=92=A4?= =?UTF-8?q?=E5=9B=9E=E7=BE=A4=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/api.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/botpy/api.py b/botpy/api.py index 09e9e31..51dcea9 100644 --- a/botpy/api.py +++ b/botpy/api.py @@ -571,6 +571,27 @@ async def recall_message(self, channel_id: str, message_id: str, hidetip: bool = ) return await self._http.request(route, params=params) + async def recall_group_message(self, group_openid: str, message_id: str) -> str: + """ + 撤回群消息。 + + 用于撤回机器人发送在当前群 group_openid 的消息 message_id,发送超出2分钟的消息不可撤回 + + Args: + group_openid (str): 群聊的 openid + message_id (str): 要撤回的消息的 ID。 + + Returns: + 成功执行返回`None`。 + """ + route = Route( + "DELETE", + "/v2/groups/{group_openid}/messages/{message_id}", + group_openid=group_openid, + message_id=message_id, + ) + return await self._http.request(route) + async def post_keyboard_message( self, channel_id: str, From d7cfde45189bda6b0f9c5eb8eace996ebdfba02a Mon Sep 17 00:00:00 2001 From: hlqian Date: Thu, 23 Nov 2023 13:54:54 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=E6=97=A5=E5=BF=97=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/botpy/logging.py b/botpy/logging.py index eee82be..3b5d463 100644 --- a/botpy/logging.py +++ b/botpy/logging.py @@ -135,7 +135,7 @@ def configure_logging( ) if _format is not None: - logging.basicConfig(format=_format) + logging.basicConfig(format=_format, force=True) if level is not None: for name, logger in logs.items(): From 230af1e3ac9d16344f918eb7a583cc4eb616b22f Mon Sep 17 00:00:00 2001 From: RexQian Date: Mon, 16 Sep 2024 15:50:49 +0800 Subject: [PATCH 4/6] =?UTF-8?q?update:=20=E5=A2=9E=E5=8A=A0=E5=A4=9A?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/types/message.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/botpy/types/message.py b/botpy/types/message.py index e916469..304726e 100644 --- a/botpy/types/message.py +++ b/botpy/types/message.py @@ -65,6 +65,7 @@ class KeyboardPayload(TypedDict, total=False): id: str content: Keyboard + class Media(TypedDict): file_uuid: str # 文件ID file_info: str # 文件信息,用于发消息接口的media字段使用 @@ -121,3 +122,19 @@ class DeletionOperator(TypedDict): class DeletedMessageInfo(TypedDict): message: DeletedMessage op_user: DeletionOperator + + +class FileType(Enum): + image = 1 + video = 2 + audio = 3 + file = 4 + + +class GroupMessageType(Enum): + text = 0 + text_image = 1 + markdown = 2 + ark = 3 + embed = 4 + media = 7 From 49b330cd88bed85510c5b251f535a46af3cfa2c6 Mon Sep 17 00:00:00 2001 From: RexQian Date: Mon, 16 Sep 2024 15:51:36 +0800 Subject: [PATCH 5/6] =?UTF-8?q?update:=20=E7=BE=A4=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=95=B0=E6=8D=AE=E5=A2=9E=E5=8A=A0id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/message.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/botpy/message.py b/botpy/message.py index 20918b4..597e65a 100644 --- a/botpy/message.py +++ b/botpy/message.py @@ -252,6 +252,7 @@ def __repr__(self): class _User: def __init__(self, data): + self.id = data.get("id", None) self.member_openid = data.get("member_openid", None) def __repr__(self): @@ -259,7 +260,8 @@ def __repr__(self): async def reply(self, **kwargs): return await self._api.post_group_message(group_openid=self.group_openid, msg_id=self.id, **kwargs) - + + class C2CMessage(BaseMessage): __slots__ = ("author",) From cc6d238691fc5209dfdedd635029393a17370f23 Mon Sep 17 00:00:00 2001 From: RexQian Date: Mon, 16 Sep 2024 15:53:41 +0800 Subject: [PATCH 6/6] =?UTF-8?q?update:=20=E8=B0=83=E6=95=B4=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=96=87=E4=BB=B6=20url=E9=BB=98=E8=AE=A4=E4=B8=BAnon?= =?UTF-8?q?e=20(url=E5=92=8Cfile=5Fdata=E4=B8=BA2=E9=80=891)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/botpy/api.py b/botpy/api.py index 51dcea9..ec883eb 100644 --- a/botpy/api.py +++ b/botpy/api.py @@ -1494,7 +1494,7 @@ async def post_group_file( self, group_openid: str, file_type: int, - url: str, + url: str = None, srv_send_msg: bool = False, file_data: str = None, ) -> message.Media: