From f9e2130b9f9590e366ff3f824722343754bf534d Mon Sep 17 00:00:00 2001 From: scjtqs Date: Sun, 6 Sep 2020 00:21:24 +0800 Subject: [PATCH] =?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图片消息失败") }