mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 19:43:49 +08:00
style: small code clean.
This commit is contained in:
parent
d266242887
commit
2f05775101
23
coolq/api.go
23
coolq/api.go
@ -418,14 +418,15 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG {
|
||||
}
|
||||
var sendNodes []*message.ForwardNode
|
||||
ts := time.Now().Add(-time.Minute * 5)
|
||||
hasCustom := func() bool {
|
||||
for _, item := range m.Array() {
|
||||
hasCustom := false
|
||||
m.ForEach(func(_, item gjson.Result) bool {
|
||||
if item.Get("data.uin").Exists() || item.Get("data.user_id").Exists() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
hasCustom = true
|
||||
return false
|
||||
}()
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
var convert func(e gjson.Result) []*message.ForwardNode
|
||||
convert = func(e gjson.Result) (nodes []*message.ForwardNode) {
|
||||
if e.Get("type").Str != "node" {
|
||||
@ -455,8 +456,8 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG {
|
||||
return
|
||||
}
|
||||
uin := e.Get("data.[user_id,uin].0").Int()
|
||||
msgTime, err := strconv.ParseInt(e.Get("data.time").Str, 10, 64)
|
||||
if err != nil {
|
||||
msgTime := e.Get("data.time").Int()
|
||||
if msgTime == 0 {
|
||||
msgTime = ts.Unix()
|
||||
}
|
||||
name := e.Get("data.name").Str
|
||||
@ -464,7 +465,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG {
|
||||
if c.IsArray() {
|
||||
flag := false
|
||||
c.ForEach(func(_, value gjson.Result) bool {
|
||||
if value.Get("type").String() == "node" {
|
||||
if value.Get("type").Str == "node" {
|
||||
flag = true
|
||||
return false
|
||||
}
|
||||
@ -520,6 +521,10 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG {
|
||||
return
|
||||
}
|
||||
if m.IsArray() {
|
||||
m.ForEach(func(_, v gjson.Result) bool {
|
||||
sendNodes = append(sendNodes, convert(v)...)
|
||||
return true
|
||||
})
|
||||
for _, item := range m.Array() {
|
||||
sendNodes = append(sendNodes, convert(item)...)
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func ToArrayMessage(e []message.IMessageElement, groupID int64) (r []MSG) {
|
||||
r = append(r, MSG{
|
||||
"type": "reply",
|
||||
"data": map[string]string{
|
||||
"id": fmt.Sprint(toGlobalID(rid, replyElem.ReplySeq)),
|
||||
"id": strconv.FormatInt(int64(toGlobalID(rid, replyElem.ReplySeq)), 10),
|
||||
"seq": strconv.FormatInt(int64(replyElem.ReplySeq), 10),
|
||||
"qq": strconv.FormatInt(replyElem.Sender, 10),
|
||||
"time": strconv.FormatInt(int64(replyElem.Time), 10),
|
||||
@ -141,7 +141,7 @@ func ToArrayMessage(e []message.IMessageElement, groupID int64) (r []MSG) {
|
||||
} else {
|
||||
r = append(r, MSG{
|
||||
"type": "reply",
|
||||
"data": map[string]string{"id": fmt.Sprint(toGlobalID(rid, replyElem.ReplySeq))},
|
||||
"data": map[string]string{"id": strconv.FormatInt(int64(toGlobalID(rid, replyElem.ReplySeq)), 10)},
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -190,7 +190,7 @@ func ToArrayMessage(e []message.IMessageElement, groupID int64) (r []MSG) {
|
||||
case *message.FaceElement:
|
||||
m = MSG{
|
||||
"type": "face",
|
||||
"data": map[string]string{"id": fmt.Sprint(o.Index)},
|
||||
"data": map[string]string{"id": strconv.FormatInt(int64(o.Index), 10)},
|
||||
}
|
||||
case *message.VoiceElement:
|
||||
m = MSG{
|
||||
|
Loading…
x
Reference in New Issue
Block a user