From 5024cc08a79c01a3c6e1d036f30e10830fb16fd5 Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sat, 5 Sep 2020 22:22:57 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/api.go | 12 +-- coolq/bot.go | 1 + coolq/cqcode.go | 271 +++++++++++++++++++++++++++--------------------- go.sum | 1 + 4 files changed, 161 insertions(+), 124 deletions(-) diff --git a/coolq/api.go b/coolq/api.go index d20bf6c..90b4ade 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -119,7 +119,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo } if m, ok := i.(gjson.Result); ok { if m.Type == gjson.JSON { - elem := bot.ConvertObjectMessage(m, true) + elem := bot.ConvertObjectMessage(m, true,groupId) fixAt(elem) mid := bot.SendGroupMessage(groupId, &message.SendingMessage{Elements: elem}) if mid == -1 { @@ -144,7 +144,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo if autoEscape { elem = append(elem, message.NewText(str)) } else { - elem = bot.ConvertStringMessage(str, true) + elem = bot.ConvertStringMessage(str, true,groupId) } fixAt(elem) mid := bot.SendGroupMessage(groupId, &message.SendingMessage{Elements: elem}) @@ -187,7 +187,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG { } return m["time"].(int32) }(), - Message: bot.ConvertStringMessage(m["message"].(string), true), + Message: bot.ConvertStringMessage(m["message"].(string), true,groupId), }) return } @@ -196,7 +196,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG { } uin, _ := strconv.ParseInt(e.Get("data.uin").Str, 10, 64) name := e.Get("data.name").Str - content := bot.ConvertObjectMessage(e.Get("data.content"), true) + content := bot.ConvertObjectMessage(e.Get("data.content"), true,groupId) if uin != 0 && name != "" && len(content) > 0 { var newElem []message.IMessageElement for _, elem := range content { @@ -242,7 +242,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b var str string if m, ok := i.(gjson.Result); ok { if m.Type == gjson.JSON { - elem := bot.ConvertObjectMessage(m, true) + elem := bot.ConvertObjectMessage(m, true,userId) mid := bot.SendPrivateMessage(userId, &message.SendingMessage{Elements: elem}) if mid == -1 { return Failed(100) @@ -265,7 +265,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b if autoEscape { elem = append(elem, message.NewText(str)) } else { - elem = bot.ConvertStringMessage(str, false) + elem = bot.ConvertStringMessage(str, false,userId) } mid := bot.SendPrivateMessage(userId, &message.SendingMessage{Elements: elem}) if mid == -1 { diff --git a/coolq/bot.go b/coolq/bot.go index 12a96e8..e32ca58 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -259,3 +259,4 @@ func (m MSG) ToJson() string { b, _ := json.Marshal(m) return string(b) } + diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 0b86843..0f8e77f 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -173,7 +173,7 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st return } -func (bot *CQBot) ConvertStringMessage(m string, group bool) (r []message.IMessageElement) { +func (bot *CQBot) ConvertStringMessage(m string, group bool, uid int64) (r []message.IMessageElement) { i := matchReg.FindAllStringSubmatchIndex(m, -1) si := 0 for _, idx := range i { @@ -205,14 +205,14 @@ func (bot *CQBot) ConvertStringMessage(m string, group bool) (r []message.IMessa ReplySeq: org["message-id"].(int32), Sender: org["sender"].(message.Sender).Uin, Time: org["time"].(int32), - Elements: bot.ConvertStringMessage(org["message"].(string), group), + Elements: bot.ConvertStringMessage(org["message"].(string), group, uid), }, }, r...) continue } } } - elem, err := bot.ToElement(t, d, group) + elem, err := bot.ToElement(t, d, group, uid) if err != nil { if !IgnoreInvalidCQCode { log.Warnf("转换CQ码 %v 到MiraiGo Element时出现错误: %v 将原样发送.", code, err) @@ -230,7 +230,7 @@ func (bot *CQBot) ConvertStringMessage(m string, group bool) (r []message.IMessa return } -func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message.IMessageElement) { +func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool, uid int64) (r []message.IMessageElement) { convertElem := func(e gjson.Result) { t := e.Get("type").Str if t == "reply" && group { @@ -249,7 +249,7 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message. ReplySeq: org["message-id"].(int32), Sender: org["sender"].(message.Sender).Uin, Time: org["time"].(int32), - Elements: bot.ConvertStringMessage(org["message"].(string), group), + Elements: bot.ConvertStringMessage(org["message"].(string), group, uid), }, }, r...) return @@ -261,7 +261,7 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message. d[key.Str] = value.Str return true }) - elem, err := bot.ToElement(t, d, group) + elem, err := bot.ToElement(t, d, group, uid) if err != nil { log.Warnf("转换CQ码到MiraiGo Element时出现错误: %v 将忽略本段CQ码.", err) return @@ -269,7 +269,7 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message. r = append(r, elem) } if m.Type == gjson.String { - return bot.ConvertStringMessage(m.Str, group) + return bot.ConvertStringMessage(m.Str, group, uid) } if m.IsArray() { for _, e := range m.Array() { @@ -282,121 +282,12 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message. return } -func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.IMessageElement, error) { +func (bot *CQBot) ToElement(t string, d map[string]string, group bool, uid int64) (message.IMessageElement, error) { switch t { case "text": return message.NewText(d["text"]), nil case "image": - f := d["file"] - if strings.HasPrefix(f, "http") || strings.HasPrefix(f, "https") { - cache := d["cache"] - if cache == "" { - cache = "1" - } - hash := md5.Sum([]byte(f)) - cacheFile := path.Join(global.CACHE_PATH, hex.EncodeToString(hash[:])+".cache") - if global.PathExists(cacheFile) && cache == "1" { - b, err := ioutil.ReadFile(cacheFile) - if err == nil { - return message.NewImage(b), nil - } - } - b, err := global.GetBytes(f) - if err != nil { - return nil, err - } - _ = ioutil.WriteFile(cacheFile, b, 0644) - return message.NewImage(b), nil - } - if strings.HasPrefix(f, "base64") { - b, err := base64.StdEncoding.DecodeString(strings.ReplaceAll(f, "base64://", "")) - if err != nil { - return nil, err - } - return message.NewImage(b), nil - } - if strings.HasPrefix(f, "file") { - fu, err := url.Parse(f) - if err != nil { - return nil, err - } - if strings.HasPrefix(fu.Path, "/") && runtime.GOOS == `windows` { - fu.Path = fu.Path[1:] - } - b, err := ioutil.ReadFile(fu.Path) - if err != nil { - return nil, err - } - return message.NewImage(b), nil - } - rawPath := path.Join(global.IMAGE_PATH, f) - if !global.PathExists(rawPath) && global.PathExists(rawPath+".cqimg") { - rawPath += ".cqimg" - } - if !global.PathExists(rawPath) && d["url"] != "" { - return bot.ToElement(t, map[string]string{"file": d["url"]}, group) - } - if global.PathExists(rawPath) { - b, err := ioutil.ReadFile(rawPath) - if err != nil { - return nil, err - } - if path.Ext(rawPath) != ".image" && path.Ext(rawPath) != ".cqimg" { - return message.NewImage(b), nil - } - if len(b) < 20 { - return nil, errors.New("invalid local file") - } - var size int32 - var hash []byte - var url string - if path.Ext(rawPath) == ".cqimg" { - for _, line := range strings.Split(global.ReadAllText(rawPath), "\n") { - kv := strings.SplitN(line, "=", 2) - switch kv[0] { - case "md5": - hash, _ = hex.DecodeString(strings.ReplaceAll(kv[1], "\r", "")) - case "size": - t, _ := strconv.Atoi(strings.ReplaceAll(kv[1], "\r", "")) - size = int32(t) - } - } - } else { - r := binary.NewReader(b) - hash = r.ReadBytes(16) - size = r.ReadInt32() - r.ReadString() - url = r.ReadString() - } - if size == 0 { - if url != "" { - return bot.ToElement(t, map[string]string{"file": url}, group) - } - return nil, errors.New("img size is 0") - } - if len(hash) != 16 { - return nil, errors.New("invalid hash") - } - if group { - rsp, err := bot.Client.QueryGroupImage(1, hash, size) - if err != nil { - if url != "" { - return bot.ToElement(t, map[string]string{"file": url}, group) - } - return nil, err - } - return rsp, nil - } - rsp, err := bot.Client.QueryFriendImage(1, hash, size) - if err != nil { - if url != "" { - return bot.ToElement(t, map[string]string{"file": url}, group) - } - return nil, err - } - return rsp, nil - } - return nil, errors.New("invalid image") + return bot.makeImageElem(t, d, group, uid) case "record": if !group { return nil, errors.New("private voice unsupported now") @@ -534,6 +425,11 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. //resid不为0的情况下走富文本通道,后续补全透传service Id,此处暂时不处理 TODO msg := message.NewRichJson(CQCodeUnescapeValue(d["data"])) return msg, nil + case "cardimage": + source := d["source"] + icon := d["icon"] + img, _ := bot.makeImageElem(t, d, group, uid) + return bot.SendNewPic(uid, img, source, icon, group) default: return nil, errors.New("unsupported cq code: " + t) } @@ -566,3 +462,142 @@ func CQCodeUnescapeValue(content string) string { ret = CQCodeUnescapeText(ret) return ret } + +// 图片 elem 生成器,单独拎出来,用于公用 +func (bot *CQBot) makeImageElem(t string, d map[string]string, group bool, uid int64) (message.IMessageElement, error) { + f := d["file"] + if strings.HasPrefix(f, "http") || strings.HasPrefix(f, "https") { + cache := d["cache"] + if cache == "" { + cache = "1" + } + hash := md5.Sum([]byte(f)) + cacheFile := path.Join(global.CACHE_PATH, hex.EncodeToString(hash[:])+".cache") + if global.PathExists(cacheFile) && cache == "1" { + b, err := ioutil.ReadFile(cacheFile) + if err == nil { + return message.NewImage(b), nil + } + } + b, err := global.GetBytes(f) + if err != nil { + return nil, err + } + _ = ioutil.WriteFile(cacheFile, b, 0644) + return message.NewImage(b), nil + } + if strings.HasPrefix(f, "base64") { + b, err := base64.StdEncoding.DecodeString(strings.ReplaceAll(f, "base64://", "")) + if err != nil { + return nil, err + } + return message.NewImage(b), nil + } + if strings.HasPrefix(f, "file") { + fu, err := url.Parse(f) + if err != nil { + return nil, err + } + if strings.HasPrefix(fu.Path, "/") && runtime.GOOS == `windows` { + fu.Path = fu.Path[1:] + } + b, err := ioutil.ReadFile(fu.Path) + if err != nil { + return nil, err + } + return message.NewImage(b), nil + } + rawPath := path.Join(global.IMAGE_PATH, f) + if !global.PathExists(rawPath) && global.PathExists(rawPath+".cqimg") { + rawPath += ".cqimg" + } + if !global.PathExists(rawPath) && d["url"] != "" { + return bot.ToElement(t, map[string]string{"file": d["url"]}, group, uid) + } + if global.PathExists(rawPath) { + b, err := ioutil.ReadFile(rawPath) + if err != nil { + return nil, err + } + if path.Ext(rawPath) != ".image" && path.Ext(rawPath) != ".cqimg" { + return message.NewImage(b), nil + } + if len(b) < 20 { + return nil, errors.New("invalid local file") + } + var size int32 + var hash []byte + var url string + if path.Ext(rawPath) == ".cqimg" { + for _, line := range strings.Split(global.ReadAllText(rawPath), "\n") { + kv := strings.SplitN(line, "=", 2) + switch kv[0] { + case "md5": + hash, _ = hex.DecodeString(strings.ReplaceAll(kv[1], "\r", "")) + case "size": + t, _ := strconv.Atoi(strings.ReplaceAll(kv[1], "\r", "")) + size = int32(t) + } + } + } else { + r := binary.NewReader(b) + hash = r.ReadBytes(16) + size = r.ReadInt32() + r.ReadString() + url = r.ReadString() + } + if size == 0 { + if url != "" { + return bot.ToElement(t, map[string]string{"file": url}, group, uid) + } + return nil, errors.New("img size is 0") + } + if len(hash) != 16 { + return nil, errors.New("invalid hash") + } + if group { + rsp, err := bot.Client.QueryGroupImage(1, hash, size) + if err != nil { + if url != "" { + return bot.ToElement(t, map[string]string{"file": url}, group, uid) + } + return nil, err + } + return rsp, nil + } + rsp, err := bot.Client.QueryFriendImage(1, hash, size) + if err != nil { + if url != "" { + return bot.ToElement(t, map[string]string{"file": url}, group, uid) + } + return nil, err + } + return rsp, nil + } + return nil, errors.New("invalid image") +} + +//SendNewPic 一种xml 方式发送的群消息图片 +func (bot *CQBot) SendNewPic(id int64, i message.ImageElement, source string, icon string, group bool) (*message.ServiceElement, error) { + var xml string + if group == false { + gm, err := bot.Client.UploadPrivateImage(id, i.Data) + if err != nil { + log.Warnf("警告: 群 %v 消息图片上传失败: %v", id, err) + return nil, err + } + xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, i.Size, "", source, icon) + + } else { + gm, err := bot.Client.UploadGroupImage(id, i.Data) + if err != nil { + log.Warnf("警告: 群 %v 消息图片上传失败: %v", id, err) + return nil, err + } + xml = fmt.Sprintf(``, "", gm.FileId, gm.Md5, i.Size, "", source, icon) + } + log.Warn(xml) + XmlMsg := message.NewRichXml(xml, 5) + return XmlMsg, nil + return nil, errors.New("发送xml图片消息失败") +} diff --git a/go.sum b/go.sum index 3eead0b..e24e526 100644 --- a/go.sum +++ b/go.sum @@ -35,6 +35,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= From 24dad3d6f97acf8a9c42dbb6634875490f91bdb5 Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sat, 5 Sep 2020 23:19:24 +0800 Subject: [PATCH 02/13] fix --- coolq/api.go | 12 +++---- coolq/bot.go | 1 - coolq/cqcode.go | 84 +++++++++++++++++++++++++++++++------------------ 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/coolq/api.go b/coolq/api.go index 90b4ade..d20bf6c 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -119,7 +119,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo } if m, ok := i.(gjson.Result); ok { if m.Type == gjson.JSON { - elem := bot.ConvertObjectMessage(m, true,groupId) + elem := bot.ConvertObjectMessage(m, true) fixAt(elem) mid := bot.SendGroupMessage(groupId, &message.SendingMessage{Elements: elem}) if mid == -1 { @@ -144,7 +144,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo if autoEscape { elem = append(elem, message.NewText(str)) } else { - elem = bot.ConvertStringMessage(str, true,groupId) + elem = bot.ConvertStringMessage(str, true) } fixAt(elem) mid := bot.SendGroupMessage(groupId, &message.SendingMessage{Elements: elem}) @@ -187,7 +187,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG { } return m["time"].(int32) }(), - Message: bot.ConvertStringMessage(m["message"].(string), true,groupId), + Message: bot.ConvertStringMessage(m["message"].(string), true), }) return } @@ -196,7 +196,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG { } uin, _ := strconv.ParseInt(e.Get("data.uin").Str, 10, 64) name := e.Get("data.name").Str - content := bot.ConvertObjectMessage(e.Get("data.content"), true,groupId) + content := bot.ConvertObjectMessage(e.Get("data.content"), true) if uin != 0 && name != "" && len(content) > 0 { var newElem []message.IMessageElement for _, elem := range content { @@ -242,7 +242,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b var str string if m, ok := i.(gjson.Result); ok { if m.Type == gjson.JSON { - elem := bot.ConvertObjectMessage(m, true,userId) + elem := bot.ConvertObjectMessage(m, true) mid := bot.SendPrivateMessage(userId, &message.SendingMessage{Elements: elem}) if mid == -1 { return Failed(100) @@ -265,7 +265,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b if autoEscape { elem = append(elem, message.NewText(str)) } else { - elem = bot.ConvertStringMessage(str, false,userId) + elem = bot.ConvertStringMessage(str, false) } mid := bot.SendPrivateMessage(userId, &message.SendingMessage{Elements: elem}) if mid == -1 { diff --git a/coolq/bot.go b/coolq/bot.go index e32ca58..12a96e8 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -259,4 +259,3 @@ func (m MSG) ToJson() string { b, _ := json.Marshal(m) return string(b) } - diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 0f8e77f..5e28579 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+?.*?]`) @@ -173,7 +172,7 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st return } -func (bot *CQBot) ConvertStringMessage(m string, group bool, uid int64) (r []message.IMessageElement) { +func (bot *CQBot) ConvertStringMessage(m string, group bool) (r []message.IMessageElement) { i := matchReg.FindAllStringSubmatchIndex(m, -1) si := 0 for _, idx := range i { @@ -205,14 +204,14 @@ func (bot *CQBot) ConvertStringMessage(m string, group bool, uid int64) (r []mes ReplySeq: org["message-id"].(int32), Sender: org["sender"].(message.Sender).Uin, Time: org["time"].(int32), - Elements: bot.ConvertStringMessage(org["message"].(string), group, uid), + Elements: bot.ConvertStringMessage(org["message"].(string), group), }, }, r...) continue } } } - elem, err := bot.ToElement(t, d, group, uid) + elem, err := bot.ToElement(t, d, group) if err != nil { if !IgnoreInvalidCQCode { log.Warnf("转换CQ码 %v 到MiraiGo Element时出现错误: %v 将原样发送.", code, err) @@ -230,7 +229,7 @@ func (bot *CQBot) ConvertStringMessage(m string, group bool, uid int64) (r []mes return } -func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool, uid int64) (r []message.IMessageElement) { +func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message.IMessageElement) { convertElem := func(e gjson.Result) { t := e.Get("type").Str if t == "reply" && group { @@ -249,7 +248,7 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool, uid int64) (r ReplySeq: org["message-id"].(int32), Sender: org["sender"].(message.Sender).Uin, Time: org["time"].(int32), - Elements: bot.ConvertStringMessage(org["message"].(string), group, uid), + Elements: bot.ConvertStringMessage(org["message"].(string), group), }, }, r...) return @@ -261,7 +260,7 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool, uid int64) (r d[key.Str] = value.Str return true }) - elem, err := bot.ToElement(t, d, group, uid) + elem, err := bot.ToElement(t, d, group) if err != nil { log.Warnf("转换CQ码到MiraiGo Element时出现错误: %v 将忽略本段CQ码.", err) return @@ -269,7 +268,7 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool, uid int64) (r r = append(r, elem) } if m.Type == gjson.String { - return bot.ConvertStringMessage(m.Str, group, uid) + return bot.ConvertStringMessage(m.Str, group) } if m.IsArray() { for _, e := range m.Array() { @@ -282,12 +281,12 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool, uid int64) (r return } -func (bot *CQBot) ToElement(t string, d map[string]string, group bool, uid int64) (message.IMessageElement, error) { +func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.IMessageElement, error) { switch t { case "text": return message.NewText(d["text"]), nil case "image": - return bot.makeImageElem(t, d, group, uid) + return bot.makeImageElem(t, d, group) case "record": if !group { return nil, errors.New("private voice unsupported now") @@ -428,8 +427,27 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool, uid int64 case "cardimage": source := d["source"] icon := d["icon"] - img, _ := bot.makeImageElem(t, d, group, uid) - return bot.SendNewPic(uid, img, source, icon, group) + minwidth, _ := strconv.ParseInt(d["minwidth"], 10, 64) + if minwidth == 0 { + minwidth = 400 + } + minheight, _ := strconv.ParseInt(d["minheight"], 10, 64) + if minheight == 0 { + minheight = 400 + } + maxwidth, _ := strconv.ParseInt(d["maxwidth"], 10, 64) + if maxwidth == 0 { + maxwidth = 500 + } + maxheight, _ := strconv.ParseInt(d["maxheight"], 10, 64) + if maxheight == 0 { + maxheight = 1000 + } + img, err := bot.makeImageElem(t, d, group) + if err != nil { + return nil, errors.New("send cardimage faild") + } + return bot.SendNewPic(img, source, icon, minwidth, minheight, maxwidth, maxheight, group) default: return nil, errors.New("unsupported cq code: " + t) } @@ -464,7 +482,7 @@ func CQCodeUnescapeValue(content string) string { } // 图片 elem 生成器,单独拎出来,用于公用 -func (bot *CQBot) makeImageElem(t string, d map[string]string, group bool, uid int64) (message.IMessageElement, error) { +func (bot *CQBot) makeImageElem(t string, d map[string]string, group bool) (message.IMessageElement, error) { f := d["file"] if strings.HasPrefix(f, "http") || strings.HasPrefix(f, "https") { cache := d["cache"] @@ -512,7 +530,7 @@ func (bot *CQBot) makeImageElem(t string, d map[string]string, group bool, uid i rawPath += ".cqimg" } if !global.PathExists(rawPath) && d["url"] != "" { - return bot.ToElement(t, map[string]string{"file": d["url"]}, group, uid) + return bot.ToElement(t, map[string]string{"file": d["url"]}, group) } if global.PathExists(rawPath) { b, err := ioutil.ReadFile(rawPath) @@ -548,7 +566,7 @@ func (bot *CQBot) makeImageElem(t string, d map[string]string, group bool, uid i } if size == 0 { if url != "" { - return bot.ToElement(t, map[string]string{"file": url}, group, uid) + return bot.ToElement(t, map[string]string{"file": url}, group) } return nil, errors.New("img size is 0") } @@ -559,7 +577,7 @@ func (bot *CQBot) makeImageElem(t string, d map[string]string, group bool, uid i rsp, err := bot.Client.QueryGroupImage(1, hash, size) if err != nil { if url != "" { - return bot.ToElement(t, map[string]string{"file": url}, group, uid) + return bot.ToElement(t, map[string]string{"file": url}, group) } return nil, err } @@ -568,7 +586,7 @@ func (bot *CQBot) makeImageElem(t string, d map[string]string, group bool, uid i rsp, err := bot.Client.QueryFriendImage(1, hash, size) if err != nil { if url != "" { - return bot.ToElement(t, map[string]string{"file": url}, group, uid) + return bot.ToElement(t, map[string]string{"file": url}, group) } return nil, err } @@ -578,26 +596,32 @@ func (bot *CQBot) makeImageElem(t string, d map[string]string, group bool, uid i } //SendNewPic 一种xml 方式发送的群消息图片 -func (bot *CQBot) SendNewPic(id int64, i message.ImageElement, source string, icon string, group bool) (*message.ServiceElement, error) { - var xml string +func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon string, minwidth int64, minheigt int64, maxwidth int64, maxheight int64, group bool) (*message.ServiceElement, error) { + var xml string + xml = "" + if i, ok := elem.(*message.ImageElement); ok { if group == false { - gm, err := bot.Client.UploadPrivateImage(id, i.Data) + gm, err := bot.Client.UploadPrivateImage(1, i.Data) if err != nil { - log.Warnf("警告: 群 %v 消息图片上传失败: %v", id, err) + log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err) return nil, err } - xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, i.Size, "", source, icon) + xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) } else { - gm, err := bot.Client.UploadGroupImage(id, i.Data) + log.Warnf(" img %d", i.Size) + gm, err := bot.Client.UploadGroupImage(1, i.Data) if err != nil { - log.Warnf("警告: 群 %v 消息图片上传失败: %v", id, err) + log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err) return nil, err } - xml = fmt.Sprintf(``, "", gm.FileId, gm.Md5, i.Size, "", source, icon) + xml = fmt.Sprintf(``, "", gm.FileId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) } + } + if xml != "" { log.Warn(xml) XmlMsg := message.NewRichXml(xml, 5) return XmlMsg, nil + } return nil, errors.New("发送xml图片消息失败") } From 6a149989284ff4f31bd114fbc32eb90a0c60ec50 Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sat, 5 Sep 2020 23:29:41 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/cqhttp.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/cqhttp.md b/docs/cqhttp.md index f491cb5..fc97bc2 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -168,7 +168,7 @@ 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 ### 设置群名 From b1fcfc6f97e12aecb7065969b65d59b747ffb8b9 Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sat, 5 Sep 2020 23:30:43 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 1 - 1 file changed, 1 deletion(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 5e28579..75905fe 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -609,7 +609,6 @@ func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon s xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) } else { - log.Warnf(" img %d", i.Size) gm, err := bot.Client.UploadGroupImage(1, i.Data) if err != nil { log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err) From f9e2130b9f9590e366ff3f824722343754bf534d Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 00:21:24 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=AF=B9=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=96=87=E4=BB=B6=E6=A0=BC=E5=BC=8F=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 8554d99..8b135f4 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -390,7 +390,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. if info.Get("artists.0").Exists() { artistName = info.Get("artists.0.name").Str } - json := fmt.Sprintf("{\"app\": \"com.tencent.structmsg\",\"desc\":\"音乐\",\"view\":\"music\",\"prompt\":\"[分享]%s\",\"ver\":\"0.0.0.1\",\"meta\":{ \"music\": { \"desc\": \"%s\", \"jumpUrl\": \"%s\", \"musicUrl\": \"%s\", \"preview\": \"%s\", \"tag\": \"网易云音乐\", \"title\":\"%s\"}}}", name,artistName, jumpUrl, musicUrl, picUrl, name) + json := fmt.Sprintf("{\"app\": \"com.tencent.structmsg\",\"desc\":\"音乐\",\"view\":\"music\",\"prompt\":\"[分享]%s\",\"ver\":\"0.0.0.1\",\"meta\":{ \"music\": { \"desc\": \"%s\", \"jumpUrl\": \"%s\", \"musicUrl\": \"%s\", \"preview\": \"%s\", \"tag\": \"网易云音乐\", \"title\":\"%s\"}}}", name, artistName, jumpUrl, musicUrl, picUrl, name) return message.NewLightApp(json), nil } if d["type"] == "custom" { @@ -615,10 +615,17 @@ func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon s xml = fmt.Sprintf(``, "", gm.FileId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) } } + if i, ok := elem.(*message.GroupImageElement); ok { + xml = fmt.Sprintf(``, "", i.ImageId, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) + } + if i, ok := elem.(*message.FriendImageElement); ok { + xml = fmt.Sprintf(``, "", i.ImageId, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) + } if xml != "" { log.Warn(xml) XmlMsg := message.NewRichXml(xml, 5) return XmlMsg, nil } + log.Warnf("elem: %+v", elem) return nil, errors.New("发送xml图片消息失败") } From 2a56475daf018a6bdad41508455977f46b1faec5 Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 00:24:04 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 1 - 1 file changed, 1 deletion(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 8b135f4..f27c5a0 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -626,6 +626,5 @@ func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon s XmlMsg := message.NewRichXml(xml, 5) return XmlMsg, nil } - log.Warnf("elem: %+v", elem) return nil, errors.New("发送xml图片消息失败") } From 793cf2e2b9548000d95cd9fc54a4fc4840d8267f Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 00:27:24 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8BLog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index f27c5a0..e4e1fb8 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -601,7 +601,7 @@ func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon s if group == false { gm, err := bot.Client.UploadPrivateImage(1, i.Data) if err != nil { - log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err) + log.Warnf("警告: 好友消息 %v 消息图片上传失败: %v", 1, err) return nil, err } xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) From 4d260be76a5b200f70676b8e072b954b6e914c4f Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 01:19:26 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E8=B0=83=E6=95=B4=20xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index e4e1fb8..8bcc570 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -604,22 +604,22 @@ func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon s log.Warnf("警告: 好友消息 %v 消息图片上传失败: %v", 1, err) return nil, err } - xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) + xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) } else { - gm, err := bot.Client.UploadGroupImage(1, i.Data) + gm, err := bot.Client.UploadGroupImage(627864759, i.Data) if err != nil { - log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err) + log.Warnf("警告: 群 %v 消息图片上传失败: %v", 627864759, err) return nil, err } - xml = fmt.Sprintf(``, "", gm.FileId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) + xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) } } if i, ok := elem.(*message.GroupImageElement); ok { - xml = fmt.Sprintf(``, "", i.ImageId, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) + xml = fmt.Sprintf(``, "", i.ImageId, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) } if i, ok := elem.(*message.FriendImageElement); ok { - xml = fmt.Sprintf(``, "", i.ImageId, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) + xml = fmt.Sprintf(``, "", i.ImageId, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) } if xml != "" { log.Warn(xml) From 514f93b527197933388830154821eac920407138 Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 01:28:31 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E8=B0=83=E6=95=B4=20xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 8bcc570..2944dca 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -607,9 +607,9 @@ func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon s xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) } else { - gm, err := bot.Client.UploadGroupImage(627864759, i.Data) + gm, err := bot.Client.UploadGroupImage(1, i.Data) if err != nil { - log.Warnf("警告: 群 %v 消息图片上传失败: %v", 627864759, err) + log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err) return nil, err } xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) From 828ca2ec3c5e65ede1ca6e3dfb3cf40c77ed31cb Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 01:38:41 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20ios=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 2944dca..ddb8119 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -604,7 +604,7 @@ func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon s log.Warnf("警告: 好友消息 %v 消息图片上传失败: %v", 1, err) return nil, err } - xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) + xml = fmt.Sprintf(``, "", gm.Md5, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) } else { gm, err := bot.Client.UploadGroupImage(1, i.Data) @@ -612,14 +612,14 @@ func (bot *CQBot) SendNewPic(elem message.IMessageElement, source string, icon s log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err) return nil, err } - xml = fmt.Sprintf(``, "", gm.ImageId, gm.Md5, len(i.Data), "", minwidth, minheigt, maxwidth, maxheight, source, icon) + 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.ImageId, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) + 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.ImageId, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) + xml = fmt.Sprintf(``, "", i.Md5, i.Md5, 0, "", minwidth, minheigt, maxwidth, maxheight, source, icon) } if xml != "" { log.Warn(xml) From ac5803a539c07f94fea3fb3e17016cf265bbd995 Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 10:39:46 +0800 Subject: [PATCH 11/13] =?UTF-8?q?xml=E5=92=8Cjson=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=BB=A5=E5=8F=8Acq=E7=A0=81=E4=B8=8A=E6=8A=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81.=20=E5=AF=8C=E6=96=87=E6=9C=AC=E7=9A=84xml=E5=92=8Cjs?= =?UTF-8?q?on=E7=9A=84=E6=B6=88=E6=81=AF=E8=AF=86=E5=88=AB=EF=BC=8C?= =?UTF-8?q?=E4=BE=9D=E8=B5=96miraigo=E7=9A=84pr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index ddb8119..ec01798 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -51,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 { @@ -113,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, " Date: Sun, 6 Sep 2020 10:42:18 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=9A=84=20=E6=96=87=E6=A1=A3=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/cqhttp.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/cqhttp.md b/docs/cqhttp.md index a91beee..6c13a80 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -123,7 +123,7 @@ Type: `node` Type: `xml` -范围: **发送** +范围: **发送/接收** 参数: @@ -172,7 +172,7 @@ Type: `xml` Type: `json` -范围: **发送** +范围: **发送/接收** 参数: From da8b0931f14aba91c1c2dcdcd7ca733a8185a39e Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 14:57:08 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E5=AE=BD=E9=AB=98=E8=B0=83=E6=95=B4=E5=88=B0=20200*200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index ec01798..76929d5 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -450,11 +450,11 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. icon := d["icon"] minwidth, _ := strconv.ParseInt(d["minwidth"], 10, 64) if minwidth == 0 { - minwidth = 400 + minwidth = 200 } minheight, _ := strconv.ParseInt(d["minheight"], 10, 64) if minheight == 0 { - minheight = 400 + minheight = 200 } maxwidth, _ := strconv.ParseInt(d["maxwidth"], 10, 64) if maxwidth == 0 {