From 19556cbab3dfb84614618cd27672117d6fa9f237 Mon Sep 17 00:00:00 2001 From: nnnewb Date: Sat, 13 Feb 2021 18:37:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=95=A5=E5=BE=AE=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=B8=8B=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/api.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/coolq/api.go b/coolq/api.go index 5e94212..607e71a 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -804,22 +804,23 @@ func (bot *CQBot) CQGetStrangerInfo(userID int64) MSG { // https://git.io/Jtz15 func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG { postType := context.Get("post_type").Str - anonymous := context.Get("anonymous") - isAnonymous := anonymous.Type != gjson.Null switch postType { case "message": + anonymous := context.Get("anonymous") + isAnonymous := anonymous.Type != gjson.Null msgType := context.Get("message_type").Str reply := operation.Get("reply") + if reply.Exists() { autoEscape := global.EnsureBool(operation.Get("auto_escape"), false) at := !isAnonymous // 除匿名消息场合外默认 true if operation.Get("at_sender").Exists() { - at = operation.Get("at_sender").Bool() + at = operation.Get("at_sender").Bool() && !isAnonymous } - if !isAnonymous && at && reply.IsArray() { + if at && reply.IsArray() { // 在 reply 数组头部插入CQ码 replySegments := make([]MSG, 0) segments := make([]MSG, 0) @@ -845,7 +846,7 @@ func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG { } reply = gjson.Parse(modified) - } else if !isAnonymous && at && reply.Type == gjson.String { + } else if at && reply.Type == gjson.String { reply = gjson.Parse(fmt.Sprintf( "\"[CQ:at,qq=%d]%s\"", context.Get("sender.user_id").Int(),