1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

fix cqcode

This commit is contained in:
wdvxdr 2021-02-17 16:04:28 +08:00
parent 02581ff8a9
commit 1ff9de190d
No known key found for this signature in database
GPG Key ID: 55FF1414A69CEBA6
3 changed files with 21 additions and 12 deletions

View File

@ -13,17 +13,14 @@ import (
"sync" "sync"
"time" "time"
"github.com/Mrs4s/MiraiGo/utils"
"github.com/syndtr/goleveldb/leveldb"
"github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/client" "github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/message" "github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
"github.com/Mrs4s/go-cqhttp/global" "github.com/Mrs4s/go-cqhttp/global"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/syndtr/goleveldb/leveldb"
) )
var json = jsoniter.ConfigCompatibleWithStandardLibrary var json = jsoniter.ConfigCompatibleWithStandardLibrary

View File

@ -361,11 +361,11 @@ func (bot *CQBot) ConvertStringMessage(msg string, isGroup bool) (r []message.IM
saveTempText := func() { saveTempText := func() {
if len(tempText) != 0 { if len(tempText) != 0 {
if SplitURL { if SplitURL {
for _, t := range global.SplitURL(CQCodeUnescapeValue(string(tempText))) { for _, t := range global.SplitURL(CQCodeUnescapeText(string(tempText))) {
r = append(r, message.NewText(t)) r = append(r, message.NewText(t))
} }
} else { } else {
r = append(r, message.NewText(CQCodeUnescapeValue(string(tempText)))) r = append(r, message.NewText(CQCodeUnescapeText(string(tempText))))
} }
} }
tempText = []rune{} tempText = []rune{}
@ -783,11 +783,11 @@ func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m inte
i, _ := strconv.ParseInt(resID, 10, 64) i, _ := strconv.ParseInt(resID, 10, 64)
if i == 0 { if i == 0 {
// 默认情况下走小程序通道 // 默认情况下走小程序通道
msg := message.NewLightApp(CQCodeUnescapeValue(d["data"])) msg := message.NewLightApp(d["data"])
return msg, nil return msg, nil
} }
// resid不为0的情况下走富文本通道后续补全透传service Id此处暂时不处理 TODO // resid不为0的情况下走富文本通道后续补全透传service Id此处暂时不处理 TODO
msg := message.NewRichJson(CQCodeUnescapeValue(d["data"])) msg := message.NewRichJson(d["data"])
return msg, nil return msg, nil
case "cardimage": case "cardimage":
source := d["source"] source := d["source"]
@ -894,6 +894,12 @@ func CQCodeEscapeText(raw string) string {
, -> , , -> ,
& -> &
[ -> [
] -> ]
*/ */
func CQCodeEscapeValue(value string) string { func CQCodeEscapeValue(value string) string {
ret := CQCodeEscapeText(value) ret := CQCodeEscapeText(value)
@ -920,7 +926,13 @@ func CQCodeUnescapeText(content string) string {
/*CQCodeUnescapeValue 将字符串content中部分字符反转义 /*CQCodeUnescapeValue 将字符串content中部分字符反转义
, -> , , -> ,
& -> &
[ -> [
] -> ]
*/ */
func CQCodeUnescapeValue(content string) string { func CQCodeUnescapeValue(content string) string {

View File

@ -109,9 +109,9 @@ func andOperatorConstruct(argument gjson.Result) *AndOperator {
} }
// Eval 对payload执行And过滤 // Eval 对payload执行And过滤
func (andOperator *AndOperator) Eval(payload MSG) bool { func (op *AndOperator) Eval(payload MSG) bool {
res := true res := true
for _, operand := range andOperator.operands { for _, operand := range op.operands {
if len(operand.key) == 0 { if len(operand.key) == 0 {
// is an operator // is an operator