diff --git a/coolq/cqcode.go b/coolq/cqcode.go
index d6e04a6..76929d5 100644
--- a/coolq/cqcode.go
+++ b/coolq/cqcode.go
@@ -6,6 +6,11 @@ import (
"encoding/hex"
"errors"
"fmt"
+ "github.com/Mrs4s/MiraiGo/binary"
+ "github.com/Mrs4s/MiraiGo/message"
+ "github.com/Mrs4s/go-cqhttp/global"
+ log "github.com/sirupsen/logrus"
+ "github.com/tidwall/gjson"
"io/ioutil"
"net/url"
"path"
@@ -13,12 +18,6 @@ import (
"runtime"
"strconv"
"strings"
-
- "github.com/Mrs4s/MiraiGo/binary"
- "github.com/Mrs4s/MiraiGo/message"
- "github.com/Mrs4s/go-cqhttp/global"
- log "github.com/sirupsen/logrus"
- "github.com/tidwall/gjson"
)
var matchReg = regexp.MustCompile(`\[CQ:\w+?.*?]`)
@@ -52,9 +51,13 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
"data": map[string]string{"text": o.Content},
}
case *message.LightAppElement:
+ //m = MSG{
+ // "type": "text",
+ // "data": map[string]string{"text": o.Content},
+ //}
m = MSG{
- "type": "text",
- "data": map[string]string{"text": o.Content},
+ "type": "json",
+ "data": map[string]string{"data": o.Content},
}
case *message.AtElement:
if o.Target == 0 {
@@ -114,6 +117,18 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
"data": map[string]string{"file": o.Filename, "url": o.Url},
}
}
+ case *message.ServiceElement:
+ if isOk := strings.Contains(o.Content, " `, "", gm.Md5, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon)
+
+ } else {
+ gm, err := bot.Client.UploadGroupImage(1, i.Data)
+ if err != nil {
+ log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err)
+ return nil, err
+ }
+ xml = fmt.Sprintf(` `, "", gm.Md5, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon)
+ }
+ }
+ if i, ok := elem.(*message.GroupImageElement); ok {
+ xml = fmt.Sprintf(` `, "", i.Md5, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon)
+ }
+ if i, ok := elem.(*message.FriendImageElement); ok {
+ xml = fmt.Sprintf(` `, "", i.Md5, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon)
+ }
+ if xml != "" {
+ log.Warn(xml)
+ XmlMsg := message.NewRichXml(xml, 5)
+ return XmlMsg, nil
+ }
+ return nil, errors.New("发送xml图片消息失败")
+}
diff --git a/docs/cqhttp.md b/docs/cqhttp.md
index bdbedef..6c13a80 100644
--- a/docs/cqhttp.md
+++ b/docs/cqhttp.md
@@ -123,7 +123,7 @@ Type: `node`
Type: `xml`
-范围: **发送**
+范围: **发送/接收**
参数:
@@ -168,11 +168,11 @@ Type: `xml`
```
-###json消息支持
+### json消息支持
Type: `json`
-范围: **发送**
+范围: **发送/接收**
参数:
@@ -198,6 +198,33 @@ json中的字符串需要进行转义:
[CQ:json,data={"app":"com.tencent.miniapp","desc":"","view":"notification","ver":"0.0.0.1","prompt":"[应用]","appID":"","sourceName":"","actionData":"","actionData_A":"","sourceUrl":"","meta":{"notification":{"appInfo":{"appName":"全国疫情数据统计","appType":4,"appid":1109659848,"iconUrl":"http:\/\/gchat.qpic.cn\/gchatpic_new\/719328335\/-2010394141-6383A777BEB79B70B31CE250142D740F\/0"},"data":[{"title":"确诊","value":"80932"},{"title":"今日确诊","value":"28"},{"title":"疑似","value":"72"},{"title":"今日疑似","value":"5"},{"title":"治愈","value":"60197"},{"title":"今日治愈","value":"1513"},{"title":"死亡","value":"3140"},{"title":"今**亡","value":"17"}],"title":"中国加油,武汉加油","button":[{"name":"病毒:SARS-CoV-2,其导致疾病命名 COVID-19","action":""},{"name":"传染源:新冠肺炎的患者。无症状感染者也可能成为传染源。","action":""}],"emphasis_keyword":""}},"text":"","sourceAd":""}]
```
+
+### cardimage 一种xml的图片消息(装逼大图)
+
+ps: xml 接口的消息都存在风控风险,请自行兼容发送失败后的处理(可以失败后走普通图片模式)
+
+Type: `cardimage`
+
+范围: **发送**
+
+参数:
+
+| 参数名 | 类型 | 说明 |
+| ------ | ------ | ------------------------------------------------------------ |
+| file | string | 和image的file字段对齐,支持也是一样的|
+| minwidth | int64 | 默认不填为400,最小width|
+| minheight | int64 | 默认不填为400,最小height|
+| maxwidth | int64 | 默认不填为500,最大width|
+| maxheight | int64 | 默认不填为1000,最大height|
+| source | string | 分享来源的名称,可以留空|
+| icon | string | 分享来源的icon图标url,可以留空|
+
+
+示例cardimage 的cq码:
+```test
+[CQ:cardimage,file=https://i.pixiv.cat/img-master/img/2020/03/25/00/00/08/80334602_p0_master1200.jpg]
+```
+
## API
### 设置群名
diff --git a/go.sum b/go.sum
index aff89db..7473e10 100644
--- a/go.sum
+++ b/go.sum
@@ -34,6 +34,7 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=