1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 03:53:50 +08:00

Merge pull request #803 from sam01101/dev.forward

修复转发信息过期导致panic
This commit is contained in:
Mrs4s 2021-04-07 19:11:47 +08:00 committed by GitHub
commit 35860a4b11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -471,7 +471,11 @@ func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMes
} }
if t == "forward" { // 单独处理转发 if t == "forward" { // 单独处理转发
if id, ok := d["id"]; ok { if id, ok := d["id"]; ok {
r = []message.IMessageElement{bot.Client.DownloadForwardMessage(id)} if fwdMsg := bot.Client.DownloadForwardMessage(id); fwdMsg == nil {
log.Warnf("警告: Forward 信息不存在或已过期")
} else {
r = []message.IMessageElement{fwdMsg}
}
} else { } else {
log.Warnf("警告: Forward 元素中必须包含 id") log.Warnf("警告: Forward 元素中必须包含 id")
} }
@ -653,7 +657,11 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, isGroup bool) (r []messag
if id == "" { if id == "" {
log.Warnf("警告: Forward 元素中必须包含 id") log.Warnf("警告: Forward 元素中必须包含 id")
} else { } else {
r = []message.IMessageElement{bot.Client.DownloadForwardMessage(id)} if fwdMsg := bot.Client.DownloadForwardMessage(id); fwdMsg == nil {
log.Warnf("警告: Forward 信息不存在或已过期")
} else {
r = []message.IMessageElement{fwdMsg}
}
} }
return return
} }