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

Fix forward msg empty panic

This commit is contained in:
Sam 2021-04-07 18:48:56 +08:00
parent e8d2d345e9
commit c06aee39d9
No known key found for this signature in database
GPG Key ID: 2057906F881702DD

View File

@ -471,7 +471,11 @@ func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMes
}
if t == "forward" { // 单独处理转发
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 {
log.Warnf("警告: Forward 元素中必须包含 id")
}
@ -653,7 +657,11 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, isGroup bool) (r []messag
if id == "" {
log.Warnf("警告: Forward 元素中必须包含 id")
} 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
}