mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
add element: ForwardElement.
This commit is contained in:
parent
36d39060b0
commit
f05d841b06
@ -316,7 +316,7 @@ func (c *QQClient) SendForwardMessage(groupCode int64, m *message.ForwardMessage
|
|||||||
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>`, m.Nodes[i].SenderName, message.ToReadableString(m.Nodes[i].Message))
|
||||||
}
|
}
|
||||||
return c.SendGroupMessage(groupCode, genForwardMessage(rsp.MsgResid, pv, "群聊的聊天记录", "[聊天记录]", "聊天记录", fmt.Sprintf("查看 %d 条转发消息", len(m.Nodes)), ts))
|
return c.SendGroupMessage(groupCode, genForwardCard(rsp.MsgResid, pv, "群聊的聊天记录", "[聊天记录]", "聊天记录", fmt.Sprintf("查看 %d 条转发消息", len(m.Nodes)), ts))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -278,7 +278,7 @@ func packRequestDataV3(data []byte) (r []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func genForwardMessage(resId, preview, title, brief, source, summary string, ts int64) *message.SendingMessage {
|
func genForwardCard(resId, preview, title, brief, source, summary string, ts int64) *message.SendingMessage {
|
||||||
template := fmt.Sprintf(`
|
template := fmt.Sprintf(`
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?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">
|
<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">
|
||||||
|
@ -53,6 +53,10 @@ type ServiceElement struct {
|
|||||||
Content string
|
Content string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ForwardElement struct {
|
||||||
|
ResId string
|
||||||
|
}
|
||||||
|
|
||||||
func NewText(s string) *TextElement {
|
func NewText(s string) *TextElement {
|
||||||
return &TextElement{Content: s}
|
return &TextElement{Content: s}
|
||||||
}
|
}
|
||||||
@ -142,6 +146,10 @@ func (e *ReplyElement) Type() ElementType {
|
|||||||
return Reply
|
return Reply
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *ForwardElement) Type() ElementType {
|
||||||
|
return Forward
|
||||||
|
}
|
||||||
|
|
||||||
var faceMap = map[int]string{
|
var faceMap = map[int]string{
|
||||||
14: "微笑",
|
14: "微笑",
|
||||||
1: "撇嘴",
|
1: "撇嘴",
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -76,6 +77,7 @@ const (
|
|||||||
At
|
At
|
||||||
Reply
|
Reply
|
||||||
Service
|
Service
|
||||||
|
Forward
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Sender) IsAnonymous() bool {
|
func (s *Sender) IsAnonymous() bool {
|
||||||
@ -307,6 +309,11 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
|
|||||||
content = string(binary.ZlibUncompress(elem.RichMsg.Template1[1:]))
|
content = string(binary.ZlibUncompress(elem.RichMsg.Template1[1:]))
|
||||||
}
|
}
|
||||||
if content != "" {
|
if content != "" {
|
||||||
|
if elem.RichMsg.ServiceId == 35 {
|
||||||
|
reg := regexp.MustCompile(`m_resid="(\w+?.*?)"`)
|
||||||
|
res = append(res, &ForwardElement{ResId: reg.FindAllStringSubmatch(content, -1)[0][1]})
|
||||||
|
continue
|
||||||
|
}
|
||||||
res = append(res, NewText(content))
|
res = append(res, NewText(content))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user