From 05d8e773f2312a56c2447bbff1b77eda943f21a5 Mon Sep 17 00:00:00 2001 From: scjtqs Date: Thu, 3 Sep 2020 00:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E5=90=88=20=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=9A=84MiraiGo=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 12 ++++++++++-- docs/cqhttp.md | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 090e06a..396a1c8 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -503,11 +503,19 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. template := CQCodeEscapeValue(d["data"]) //println(template) i, _ := strconv.ParseInt(resId, 10, 64) - msg := message.NewXmlMsg(template, i) + msg := message.NewRichXml(template, i) return msg, nil case "json": + resId := d["resid"] + i, _ := strconv.ParseInt(resId, 10, 64) log.Warnf("json msg=%s", d["data"]) - msg := message.NewJsonMsg(CQCodeUnescapeValue(d["data"])) + if i == 0 { + //默认情况下走小程序通道 + msg := message.NewLightApp(CQCodeUnescapeValue(d["data"])) + return msg, nil + } + //resid不为0的情况下走富文本通道,后续补全透传service Id,此处暂时不处理 TODO + msg := message.NewRichJson(CQCodeUnescapeValue(d["data"])) return msg, nil default: return nil, errors.New("unsupported cq code: " + t) diff --git a/docs/cqhttp.md b/docs/cqhttp.md index f664276..f491cb5 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -179,6 +179,7 @@ Type: `json` | 参数名 | 类型 | 说明 | | ------ | ------ | ------------------------------------------------------------ | | data | string | json内容,json的所有字符串记得实体化处理| +| resid | int32 | 默认不填为0,走小程序通道,填了走富文本通道发送| json中的字符串需要进行转义: