diff --git a/coolq/api.go b/coolq/api.go index fef0c91..2ef3500 100644 --- a/coolq/api.go +++ b/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() { - if item.Get("data.uin").Exists() || item.Get("data.user_id").Exists() { - return true - } + hasCustom := false + m.ForEach(func(_, item gjson.Result) bool { + if item.Get("data.uin").Exists() || item.Get("data.user_id").Exists() { + hasCustom = true + return false } - 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)...) } diff --git a/coolq/cqcode.go b/coolq/cqcode.go index e92e665..d46461e 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -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{