From 7e750352c4e16339393e4ea531e0f46dfee3d957 Mon Sep 17 00:00:00 2001 From: Akiba Date: Sat, 25 Jun 2022 21:06:37 +0800 Subject: [PATCH 1/2] fix: #1558 --- coolq/api.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/coolq/api.go b/coolq/api.go index a16636e..7b5b95f 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -875,6 +875,12 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType i := e.Get("data.id").Int() m, _ := db.GetMessageByGlobalID(int32(i)) if m != nil { + mSource := func() message.SourceType { + if m.GetType() == "group" { + return message.SourceGroup + } + return message.SourcePrivate + }() msgTime := m.GetAttribute().Timestamp if msgTime == 0 { msgTime = ts.Unix() @@ -883,7 +889,7 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType SenderId: m.GetAttribute().SenderUin, SenderName: m.GetAttribute().SenderName, Time: int32(msgTime), - Message: resolveElement(bot.ConvertContentMessage(m.GetContent(), message.SourceGroup)), + Message: resolveElement(bot.ConvertContentMessage(m.GetContent(), mSource)), } } log.Warnf("警告: 引用消息 %v 错误或数据库未开启.", e.Get("data.id").Str) @@ -916,7 +922,7 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType } } } - content := bot.ConvertObjectMessage(c, message.SourceGroup) + content := bot.ConvertObjectMessage(c, sourceType) if uin != 0 && name != "" && len(content) > 0 { return &message.ForwardNode{ SenderId: uin, From a0fba6ad540e5cfdd9e06c8b90fb81260faa0ded Mon Sep 17 00:00:00 2001 From: Akiba Date: Sat, 25 Jun 2022 21:21:16 +0800 Subject: [PATCH 2/2] fix: #1557 --- coolq/api.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/coolq/api.go b/coolq/api.go index 7b5b95f..e1186df 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -832,7 +832,12 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType groupID := target source := message.Source{SourceType: sourceType, PrimaryID: target} if sourceType == message.SourcePrivate { - groupID = 0 + // ios 设备的合并转发来源群号不能为 0 + if len(bot.Client.GroupList) == 0 { + groupID = 1 + } else { + groupID = bot.Client.GroupList[1].Uin + } } builder := bot.Client.NewForwardMessageBuilder(groupID) @@ -875,12 +880,10 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType i := e.Get("data.id").Int() m, _ := db.GetMessageByGlobalID(int32(i)) if m != nil { - mSource := func() message.SourceType { - if m.GetType() == "group" { - return message.SourceGroup - } - return message.SourcePrivate - }() + mSource := message.SourcePrivate + if m.GetType() == "group" { + mSource = message.SourceGroup + } msgTime := m.GetAttribute().Timestamp if msgTime == 0 { msgTime = ts.Unix()