Skip to content

Commit 67ea5d7

Browse files
authored
Merge pull request #1559 from Akegarasu/fix-forwardmsg
Fix forward msg
2 parents f772996 + a0fba6a commit 67ea5d7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

coolq/api.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,12 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType
832832
groupID := target
833833
source := message.Source{SourceType: sourceType, PrimaryID: target}
834834
if sourceType == message.SourcePrivate {
835-
groupID = 0
835+
// ios 设备的合并转发来源群号不能为 0
836+
if len(bot.Client.GroupList) == 0 {
837+
groupID = 1
838+
} else {
839+
groupID = bot.Client.GroupList[1].Uin
840+
}
836841
}
837842
builder := bot.Client.NewForwardMessageBuilder(groupID)
838843

@@ -875,6 +880,10 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType
875880
i := e.Get("data.id").Int()
876881
m, _ := db.GetMessageByGlobalID(int32(i))
877882
if m != nil {
883+
mSource := message.SourcePrivate
884+
if m.GetType() == "group" {
885+
mSource = message.SourceGroup
886+
}
878887
msgTime := m.GetAttribute().Timestamp
879888
if msgTime == 0 {
880889
msgTime = ts.Unix()
@@ -883,7 +892,7 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType
883892
SenderId: m.GetAttribute().SenderUin,
884893
SenderName: m.GetAttribute().SenderName,
885894
Time: int32(msgTime),
886-
Message: resolveElement(bot.ConvertContentMessage(m.GetContent(), message.SourceGroup)),
895+
Message: resolveElement(bot.ConvertContentMessage(m.GetContent(), mSource)),
887896
}
888897
}
889898
log.Warnf("警告: 引用消息 %v 错误或数据库未开启.", e.Get("data.id").Str)
@@ -916,7 +925,7 @@ func (bot *CQBot) uploadForwardElement(m gjson.Result, target int64, sourceType
916925
}
917926
}
918927
}
919-
content := bot.ConvertObjectMessage(c, message.SourceGroup)
928+
content := bot.ConvertObjectMessage(c, sourceType)
920929
if uin != 0 && name != "" && len(content) > 0 {
921930
return &message.ForwardNode{
922931
SenderId: uin,

0 commit comments

Comments
 (0)