From 163c2c729064e4b95babcd6451f5b96ef54aac98 Mon Sep 17 00:00:00 2001 From: Checkey_01 Date: Mon, 11 Dec 2023 00:56:47 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86GroupMess?= =?UTF-8?q?age.=5F=5Frepr=5F=5F()=E8=BF=94=E5=9B=9E=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E7=BC=BA=E5=B0=91author=E5=92=8Cgroup=5Fopenid?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/botpy/message.py b/botpy/message.py index 22f75c1..128db06 100644 --- a/botpy/message.py +++ b/botpy/message.py @@ -233,7 +233,7 @@ def __repr__(self): return str(self.__dict__) class GroupMessage(BaseMessage): - __slots___ = ( + __slots__ = ( "author", "group_openid" ) @@ -252,7 +252,7 @@ def __init__(self, data): self.member_openid = data.get("member_openid", None) def __repr__(self): - return str(__dict__) + return str(self.__dict__) async def reply(self, **kwargs): return await self._api.post_group_message(group_openid=self.group_openid, msg_id=self.id, **kwargs) From 572ab01b2ae50d03cbb66dcaed2a886bbb69558d Mon Sep 17 00:00:00 2001 From: Checkey_01 Date: Mon, 11 Dec 2023 01:05:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E5=8F=91=E9=80=81=E5=8D=95?= =?UTF-8?q?=E8=81=8A=E5=92=8C=E7=BE=A4=E8=81=8A=E7=9A=84=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=97=B6=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8msg=5Fseq=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/botpy/api.py b/botpy/api.py index b9a627a..f6e3d01 100644 --- a/botpy/api.py +++ b/botpy/api.py @@ -1323,6 +1323,7 @@ async def post_group_message( message_reference: message.Reference = None, media: message.Media = None, msg_id: str = None, + msg_seq: str = 1, event_id: str = None, markdown: message.MarkdownPayload = None, keyboard: message.Keyboard = None, @@ -1345,6 +1346,7 @@ async def post_group_message( message_reference (message.Reference): 对消息的引用。 media (message.Media): 富媒体消息 msg_id (str): 您要回复的消息的 ID。 + msg_seq (int): 回复消息的序号,与 msg_id 联合使用,默认是1。相同的 msg_id + msg_seq 重复发送会失败。 event_id (str): 您要回复的消息的事件 ID。 markdown (message.MarkdownPayload): markdown 消息 keyboard (message.Keyboard): keyboard 消息 @@ -1367,6 +1369,7 @@ async def post_c2c_message( message_reference: message.Reference = None, media: message.Media = None, msg_id: str = None, + msg_seq: str = 1, event_id: str = None, markdown: message.MarkdownPayload = None, keyboard: message.Keyboard = None, @@ -1389,6 +1392,7 @@ async def post_c2c_message( message_reference (message.Reference): 对消息的引用。 media (message.Media): 富媒体消息 msg_id (str): 您要回复的消息的 ID。 + msg_seq (int): 回复消息的序号,与 msg_id 联合使用,默认是1。相同的 msg_id + msg_seq 重复发送会失败。 event_id (str): 您要回复的消息的事件 ID。 markdown (message.MarkdownPayload): markdown 消息 keyboard (message.Keyboard): keyboard 消息 From 5f10bb7b0c8e95578a37012b24cd5720a571d412 Mon Sep 17 00:00:00 2001 From: Checkey_01 Date: Tue, 12 Dec 2023 18:29:39 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=96=87=E6=9C=AC=E4=B8=AD=E5=87=BA=E7=8E=B0=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E4=BC=9A=E9=94=99=E8=AF=AF=E6=BF=80=E6=B4=BB=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/ext/command_util.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/botpy/ext/command_util.py b/botpy/ext/command_util.py index 8f26b2b..c05eb83 100644 --- a/botpy/ext/command_util.py +++ b/botpy/ext/command_util.py @@ -20,10 +20,12 @@ async def decorated(*args, **kwargs): message: BaseMessage = kwargs["message"] for command in self.commands: if command in message.content: - # 分割指令后面的指令参数 - params = message.content.split(command)[1].strip() - kwargs["params"] = params - return await func(*args, **kwargs) + content_split = message.content.lstrip().split(command) + # 当指令出现在消息文本的开头执行指令 + if len(content_split[0]) == 0: + # 分割指令后面的指令参数 + kwargs["params"] = content_split[1].strip() + return await func(*args, **kwargs) return False return decorated From 9b3c9af3642322f4965f65b85782f7c99374ea6d Mon Sep 17 00:00:00 2001 From: Checkey_01 Date: Tue, 19 Dec 2023 17:51:46 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E9=A2=91?= =?UTF-8?q?=E9=81=93@=E6=9C=BA=E5=99=A8=E4=BA=BA=E6=97=B6=E8=8B=A5@?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=9C=A8=E6=B6=88=E6=81=AF=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E5=BC=80=E5=A4=B4=E6=97=A0=E6=B3=95=E8=A7=A6=E5=8F=91=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- botpy/ext/command_util.py | 6 ++++-- botpy/message.py | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/botpy/ext/command_util.py b/botpy/ext/command_util.py index c05eb83..979b5d9 100644 --- a/botpy/ext/command_util.py +++ b/botpy/ext/command_util.py @@ -20,8 +20,10 @@ async def decorated(*args, **kwargs): message: BaseMessage = kwargs["message"] for command in self.commands: if command in message.content: - content_split = message.content.lstrip().split(command) - # 当指令出现在消息文本的开头执行指令 + # 剔除消息文本中@机器人的字符串 + content = message.content.replace(f"<@!{(await message.api.me())['id']}>", "") + content_split = content.lstrip().split(command) + # 当指令出现在消息文本(已剔除@机器人的信息)的开头执行指令 if len(content_split[0]) == 0: # 分割指令后面的指令参数 kwargs["params"] = content_split[1].strip() diff --git a/botpy/message.py b/botpy/message.py index 128db06..123628b 100644 --- a/botpy/message.py +++ b/botpy/message.py @@ -231,7 +231,12 @@ def __init__(self, data): def __repr__(self): return str(self.__dict__) - + + @property + def api(self): + return self._api + + class GroupMessage(BaseMessage): __slots__ = ( "author",