diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 4c5e8b4..cc569ea 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -470,6 +470,9 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. i, _ := strconv.ParseInt(resId, 10, 64) msg := global.NewXmlMsg(template, i) return msg, nil + case "json": + msg := global.NewJsonMsg(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 a0f5c42..457cd4a 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -135,8 +135,11 @@ Type: `xml` 示例: `[CQ:xml,data=xxxx]` ####一些xml样例 + ####ps:重要:xml中的value部分,记得html实体化处理后,再打加入到cq码中 + #### qq音乐 + ```xml ``` @@ -165,6 +168,9 @@ Type: `xml` ``` +###json消息支持 + +json中的","逗号,需要转义成`,`,否则无法正确得到解析 ## API diff --git a/global/net.go b/global/net.go index d3cf1a7..b0bf936 100644 --- a/global/net.go +++ b/global/net.go @@ -59,3 +59,12 @@ func NewXmlMsg(template string,ResId int64) *message.ServiceElement{ SubType: "xml", } } + +func NewJsonMsg(template string) *message.ServiceElement{ + return &message.ServiceElement{ + Id: 1, + Content: template, + ResId: "1", + SubType: "json", + } +}