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