mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-06 03:53:50 +08:00
Merge branch 'master' of https://github.com/Mrs4s/MiraiGo
This commit is contained in:
commit
f40ac95fff
@ -1,10 +1,12 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
@ -576,6 +578,12 @@ func packUniRequestData(data []byte) (r []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func XmlEscape(c string) string {
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
_ = xml.EscapeText(buf, []byte(c))
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
func genForwardTemplate(resId, preview, title, brief, source, summary string, ts int64, items []*msg.PbMultiMsgItem) *message.ForwardElement {
|
func genForwardTemplate(resId, preview, title, brief, source, summary string, ts int64, items []*msg.PbMultiMsgItem) *message.ForwardElement {
|
||||||
template := fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8'?><msg serviceID="35" templateID="1" action="viewMultiMsg" brief="%s" m_resid="%s" m_fileName="%d" tSum="3" sourceMsgId="0" url="" flag="3" adverSign="0" multiMsgFlag="0"><item layout="1"><title color="#000000" size="34">%s</title> %s<hr></hr><summary size="26" color="#808080">%s</summary></item><source name="%s"></source></msg>`,
|
template := fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8'?><msg serviceID="35" templateID="1" action="viewMultiMsg" brief="%s" m_resid="%s" m_fileName="%d" tSum="3" sourceMsgId="0" url="" flag="3" adverSign="0" multiMsgFlag="0"><item layout="1"><title color="#000000" size="34">%s</title> %s<hr></hr><summary size="26" color="#808080">%s</summary></item><source name="%s"></source></msg>`,
|
||||||
brief, resId, ts, title, preview, summary, source,
|
brief, resId, ts, title, preview, summary, source,
|
||||||
@ -587,9 +595,9 @@ func genForwardTemplate(resId, preview, title, brief, source, summary string, ts
|
|||||||
}
|
}
|
||||||
return &message.ForwardElement{
|
return &message.ForwardElement{
|
||||||
FileName: strconv.FormatInt(ts, 10),
|
FileName: strconv.FormatInt(ts, 10),
|
||||||
Content: template,
|
Content: template,
|
||||||
ResId: resId,
|
ResId: resId,
|
||||||
Items: items,
|
Items: items,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +609,7 @@ func genLongTemplate(resId, brief string, ts int64) *message.ServiceElement {
|
|||||||
return brief
|
return brief
|
||||||
}()
|
}()
|
||||||
template := fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="35" templateID="1" action="viewMultiMsg" brief="%s" m_resid="%s" m_fileName="%d" sourceMsgId="0" url="" flag="3" adverSign="0" multiMsgFlag="1"> <item layout="1"> <title>%s</title> <hr hidden="false" style="0"/> <summary>点击查看完整消息</summary> </item> <source name="聊天记录" icon="" action="" appid="-1"/> </msg>`,
|
template := fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="35" templateID="1" action="viewMultiMsg" brief="%s" m_resid="%s" m_fileName="%d" sourceMsgId="0" url="" flag="3" adverSign="0" multiMsgFlag="1"> <item layout="1"> <title>%s</title> <hr hidden="false" style="0"/> <summary>点击查看完整消息</summary> </item> <source name="聊天记录" icon="" action="" appid="-1"/> </msg>`,
|
||||||
limited, resId, ts, limited,
|
XmlEscape(limited), resId, ts, XmlEscape(limited),
|
||||||
)
|
)
|
||||||
return &message.ServiceElement{
|
return &message.ServiceElement{
|
||||||
Id: 35,
|
Id: 35,
|
||||||
|
@ -192,7 +192,7 @@ func (c *QQClient) UploadGroupForwardMessage(groupCode int64, m *message.Forward
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
var pv string
|
var pv string
|
||||||
for i := 0; i < int(math.Min(4, float64(len(m.Nodes)))); i++ {
|
for i := 0; i < int(math.Min(4, float64(len(m.Nodes)))); i++ {
|
||||||
pv += fmt.Sprintf(`<title size="26" color="#777777">%s: %s</title>`, m.Nodes[i].SenderName, message.ToReadableString(m.Nodes[i].Message))
|
pv += fmt.Sprintf(`<title size="26" color="#777777">%s: %s</title>`, XmlEscape(m.Nodes[i].SenderName), XmlEscape(message.ToReadableString(m.Nodes[i].Message)))
|
||||||
}
|
}
|
||||||
return genForwardTemplate(rsp.MsgResid, pv, "群聊的聊天记录", "[聊天记录]", "聊天记录", fmt.Sprintf("查看 %d 条转发消息", len(m.Nodes)), ts, items)
|
return genForwardTemplate(rsp.MsgResid, pv, "群聊的聊天记录", "[聊天记录]", "聊天记录", fmt.Sprintf("查看 %d 条转发消息", len(m.Nodes)), ts, items)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user