From a6cbd226e1ac5e3484d6008ca302b51da8808f77 Mon Sep 17 00:00:00 2001 From: RockChinQ <1010553892@qq.com> Date: Tue, 1 Aug 2023 10:13:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=BE=A4=E5=86=85=E5=9B=9E=E5=A4=8D=E6=97=B6at=E5=8F=91?= =?UTF-8?q?=E9=80=81=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config-template.py | 4 +++- pkg/qqbot/manager.py | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/config-template.py b/config-template.py index 64e67ae..59e83a0 100644 --- a/config-template.py +++ b/config-template.py @@ -152,7 +152,6 @@ response_rules = { } - # 消息忽略规则 # 适用于私聊及群聊 # 符合此规则的消息将不会被响应 @@ -238,6 +237,9 @@ image_api_params = { # 群内回复消息时是否引用原消息 quote_origin = True +# 群内回复消息时是否at发送者 +at_sender = False + # 回复绘图时是否包含图片描述 include_image_description = True diff --git a/pkg/qqbot/manager.py b/pkg/qqbot/manager.py index 8a4b911..2d8c109 100644 --- a/pkg/qqbot/manager.py +++ b/pkg/qqbot/manager.py @@ -264,8 +264,24 @@ class QQBotManager: else: self.reply_filter = pkg.qqbot.filter.ReplyFilter([]) - def send(self, event, msg, check_quote=True): + def send(self, event, msg, check_quote=True, check_at_sender=True): config = pkg.utils.context.get_config() + + if check_at_sender and config.at_sender: + msg.insert( + 0, + Plain(" \n") + ) + + # 当回复的正文中包含换行时,quote可能会自带at,此时就不再单独添加at,只添加换行 + if "\n" not in str(msg[1]) or config.msg_source_adapter == 'nakuru': + msg.insert( + 0, + At( + event.sender.id + ) + ) + self.adapter.reply_message( event, msg, @@ -313,7 +329,7 @@ class QQBotManager: reply = [tips_custom.reply_message] if reply: - return self.send(event, reply, check_quote=False) + return self.send(event, reply, check_quote=False, check_at_sender=False) # 群消息处理 def on_group_message(self, event: GroupMessage):