Merge pull request #524 from RockChinQ/feat-at-sender

[Feat] 支持在群内回复时at发送者
This commit is contained in:
Junyan Qin 2023-08-01 10:14:34 +08:00 committed by GitHub
commit cba6aab48d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -152,7 +152,6 @@ response_rules = {
}
# 消息忽略规则
# 适用于私聊及群聊
# 符合此规则的消息将不会被响应
@ -238,6 +237,9 @@ image_api_params = {
# 群内回复消息时是否引用原消息
quote_origin = True
# 群内回复消息时是否at发送者
at_sender = False
# 回复绘图时是否包含图片描述
include_image_description = True

View File

@ -65,6 +65,7 @@
"size": "256x256"
},
"quote_origin": true,
"at_sender": false,
"include_image_description": true,
"process_message_timeout": 30,
"show_prefix": false,

View File

@ -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):