mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 19:43:49 +08:00
Merge pull request #657 from Akegarasu/develop
add cardimage brief support #478
This commit is contained in:
commit
f1a1b0ec30
@ -792,6 +792,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m inte
|
|||||||
case "cardimage":
|
case "cardimage":
|
||||||
source := d["source"]
|
source := d["source"]
|
||||||
icon := d["icon"]
|
icon := d["icon"]
|
||||||
|
brief := d["brief"]
|
||||||
minWidth, _ := strconv.ParseInt(d["minwidth"], 10, 64)
|
minWidth, _ := strconv.ParseInt(d["minwidth"], 10, 64)
|
||||||
if minWidth == 0 {
|
if minWidth == 0 {
|
||||||
minWidth = 200
|
minWidth = 200
|
||||||
@ -812,7 +813,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m inte
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("send cardimage faild")
|
return nil, errors.New("send cardimage faild")
|
||||||
}
|
}
|
||||||
return bot.makeShowPic(img, source, icon, minWidth, minHeight, maxWidth, maxHeight, isGroup)
|
return bot.makeShowPic(img, source, brief, icon, minWidth, minHeight, maxWidth, maxHeight, isGroup)
|
||||||
case "video":
|
case "video":
|
||||||
cache := d["cache"]
|
cache := d["cache"]
|
||||||
if cache == "" {
|
if cache == "" {
|
||||||
@ -1102,9 +1103,12 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// makeShowPic 一种xml 方式发送的群消息图片
|
// makeShowPic 一种xml 方式发送的群消息图片
|
||||||
func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, icon string, minWidth int64, minHeight int64, maxWidth int64, maxHeight int64, group bool) ([]message.IMessageElement, error) {
|
func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, brief string, icon string, minWidth int64, minHeight int64, maxWidth int64, maxHeight int64, group bool) ([]message.IMessageElement, error) {
|
||||||
xml := ""
|
xml := ""
|
||||||
var suf message.IMessageElement
|
var suf message.IMessageElement
|
||||||
|
if brief == "" {
|
||||||
|
brief = "[分享]我看到一张很赞的图片,分享给你,快来看!"
|
||||||
|
}
|
||||||
if i, ok := elem.(*LocalImageElement); ok {
|
if i, ok := elem.(*LocalImageElement); ok {
|
||||||
if !group {
|
if !group {
|
||||||
gm, err := bot.UploadLocalImageAsPrivate(1, i)
|
gm, err := bot.UploadLocalImageAsPrivate(1, i)
|
||||||
@ -1113,7 +1117,7 @@ func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, icon
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
suf = gm
|
suf = gm
|
||||||
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="[分享]我看到一张很赞的图片,分享给你,快来看!" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, "", gm.Md5, gm.Md5, len(i.Data), "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="%s" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, brief, "", gm.Md5, gm.Md5, len(i.Data), "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
||||||
} else {
|
} else {
|
||||||
gm, err := bot.UploadLocalImageAsGroup(1, i)
|
gm, err := bot.UploadLocalImageAsGroup(1, i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1121,16 +1125,16 @@ func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, icon
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
suf = gm
|
suf = gm
|
||||||
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="[分享]我看到一张很赞的图片,分享给你,快来看!" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, "", gm.Md5, gm.Md5, len(i.Data), "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="%s" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, brief, "", gm.Md5, gm.Md5, len(i.Data), "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if i, ok := elem.(*message.GroupImageElement); ok {
|
if i, ok := elem.(*message.GroupImageElement); ok {
|
||||||
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="[分享]我看到一张很赞的图片,分享给你,快来看!" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, "", i.Md5, i.Md5, 0, "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="%s" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, brief, "", i.Md5, i.Md5, 0, "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
||||||
suf = i
|
suf = i
|
||||||
}
|
}
|
||||||
if i, ok := elem.(*message.FriendImageElement); ok {
|
if i, ok := elem.(*message.FriendImageElement); ok {
|
||||||
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="[分享]我看到一张很赞的图片,分享给你,快来看!" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, "", i.Md5, i.Md5, 0, "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="%s" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, brief, "", i.Md5, i.Md5, 0, "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
||||||
suf = i
|
suf = i
|
||||||
}
|
}
|
||||||
if xml != "" {
|
if xml != "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user