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

fix: send temp message

(cherry picked from commit cebf9c25e1262f0093abc317c0c99f93400e7934)
This commit is contained in:
Kanri 2021-04-02 12:40:46 +08:00 committed by wdvxdr
parent c24a2b327a
commit 2f227842f7
No known key found for this signature in database
GPG Key ID: 55FF1414A69CEBA6

View File

@ -294,19 +294,20 @@ func (bot *CQBot) SendPrivateMessage(target int64, groupId int64, m *message.Sen
if msg != nil { if msg != nil {
id = bot.InsertPrivateMessage(msg) id = bot.InsertPrivateMessage(msg)
} }
} else if code, ok := bot.tempMsgCache.Load(target); ok || groupId != 0 { // 临时会话 } else if code, ok := bot.tempMsgCache.Load(target); ok || groupID != 0 { // 临时会话
if bot.Client.FindGroup(groupId) == nil { switch {
log.Errorf("错误: 找不到群(%v)", groupId) case groupID != 0 && bot.Client.FindGroup(groupID) == nil:
log.Errorf("错误: 找不到群(%v)", groupID)
id = -1 id = -1
} else if groupId != 0 && !bot.Client.FindGroup(groupId).AdministratorOrOwner() { case groupID != 0 && !bot.Client.FindGroup(groupID).AdministratorOrOwner():
log.Errorf("错误: 机器人在群(%v) 为非管理员或群主, 无法主动发起临时会话", groupId) log.Errorf("错误: 机器人在群(%v) 为非管理员或群主, 无法主动发起临时会话", groupID)
id = -1 id = -1
} else if groupId != 0 && bot.Client.FindGroup(groupId).FindMember(target) == nil { case groupID != 0 && bot.Client.FindGroup(groupID).FindMember(target) == nil:
log.Errorf("错误: 群员(%v) 不在 群(%v), 无法发起临时会话", target, groupId) log.Errorf("错误: 群员(%v) 不在 群(%v), 无法发起临时会话", target, groupID)
id = -1 id = -1
} else { default:
if code != nil { if code != nil && groupID == 0 {
groupId = code.(int64) groupID = code.(int64)
} }
msg := bot.Client.SendTempMessage(groupId, target, m) msg := bot.Client.SendTempMessage(groupId, target, m)
if msg != nil { if msg != nil {