From e0ce4981ae042acacaadb4b3c3e047dddf86de29 Mon Sep 17 00:00:00 2001 From: SanaeFox <36219542+Hoshinonyaruko@users.noreply.github.com> Date: Wed, 21 Aug 2024 02:12:59 +0800 Subject: [PATCH] Beta488 (#493) * beta447 * beta448 * beta449 * beta450 * beta451 * beta452 * beta453 * beta454 * beta455 * btea455 * beta456 * beta457 * beta458 * beta460 * beta460 * beta461 * beta462 * beta463 * beta464 * beta465 * beta467 * beta468 * beta469 * beta470 * beta471 * beta472 * beta473 * beta473 * beta475 * beta476 * beta478 * beta479 * beta479 * beta480 * beta481 * beta482 * beta483 * beta484 * beta485 * beta486 * beta486 * beta487 * beta487 --- Processor/ProcessC2CMessage.go | 32 ++++++++++++++++++++---- Processor/ProcessGroupMessage.go | 42 ++++++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/Processor/ProcessC2CMessage.go b/Processor/ProcessC2CMessage.go index 4ab7357f..6144444f 100644 --- a/Processor/ProcessC2CMessage.go +++ b/Processor/ProcessC2CMessage.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "strconv" + "strings" "time" "github.com/hoshinonyaruko/gensokyo/config" @@ -349,11 +350,32 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error { selfid64 = int64(p.Settings.AppID) } - //转换at - messageText := handlers.RevertTransformedText(data, "group_private", p.Api, p.Apiv2, 0, 0, config.GetWhiteEnable(5)) - if messageText == "" { - mylog.Printf("信息被自定义黑白名单拦截") - return nil + var messageText string + //当屏蔽错误通道时候=性能模式 不解析at 不解析图片 + if !config.GetDisableErrorChan() { + //转换at + messageText = handlers.RevertTransformedText(data, "group_private", p.Api, p.Apiv2, 0, 0, config.GetWhiteEnable(5)) + if messageText == "" { + mylog.Printf("信息被自定义黑白名单拦截") + return nil + } + } else { + messageText = data.Content + if messageText == "/ " { + messageText = " " + } + if messageText == " / " { + messageText = " " + } + messageText = strings.TrimSpace(messageText) + + // 检查是否需要移除前缀 + if config.GetRemovePrefixValue() { + // 移除消息内容中第一次出现的 "/" + if idx := strings.Index(messageText, "/"); idx != -1 { + messageText = messageText[:idx] + messageText[idx+1:] + } + } } groupMsg := OnebotGroupMessageS{ diff --git a/Processor/ProcessGroupMessage.go b/Processor/ProcessGroupMessage.go index 54ade658..802666c7 100644 --- a/Processor/ProcessGroupMessage.go +++ b/Processor/ProcessGroupMessage.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "strconv" + "strings" "time" "github.com/hoshinonyaruko/gensokyo/config" @@ -75,18 +76,45 @@ func (p *Processors) ProcessGroupMessage(data *dto.WSGroupATMessageData) error { } } - // 转换at - messageText := handlers.RevertTransformedText(data, "group", p.Api, p.Apiv2, GroupID64, userid64, config.GetWhiteEnable(4)) - if messageText == "" { - mylog.Printf("信息被自定义黑白名单拦截") - return nil + var messageText string + //当屏蔽错误通道时候=性能模式 不解析at 不解析图片 + if !config.GetDisableErrorChan() { + // 转换at + messageText = handlers.RevertTransformedText(data, "group", p.Api, p.Apiv2, GroupID64, userid64, config.GetWhiteEnable(4)) + if messageText == "" { + mylog.Printf("信息被自定义黑白名单拦截") + return nil + } + + //框架内指令 + p.HandleFrameworkCommand(messageText, data, "group") + } else { + // 减少无用的性能开支 + messageText = data.Content + + if messageText == "/ " { + messageText = " " + } + + if messageText == " / " { + messageText = " " + } + messageText = strings.TrimSpace(messageText) + + // 检查是否需要移除前缀 + if config.GetRemovePrefixValue() { + // 移除消息内容中第一次出现的 "/" + if idx := strings.Index(messageText, "/"); idx != -1 { + messageText = messageText[:idx] + messageText[idx+1:] + } + } + } + //群没有at,但用户可以选择加一个 if config.GetAddAtGroup() { messageText = "[CQ:at,qq=" + config.GetAppIDStr() + "] " + messageText } - //框架内指令 - p.HandleFrameworkCommand(messageText, data, "group") var messageID int //映射str的messageID到int