Skip to content

Commit

Permalink
fix: send temp message
Browse files Browse the repository at this point in the history
(cherry picked from commit cebf9c2)
  • Loading branch information
kanrichan authored and wdvxdr1123 committed Apr 30, 2021
1 parent c24a2b3 commit 2f22784
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions coolq/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,20 @@ func (bot *CQBot) SendPrivateMessage(target int64, groupId int64, m *message.Sen
if msg != nil {
id = bot.InsertPrivateMessage(msg)
}
} else if code, ok := bot.tempMsgCache.Load(target); ok || groupId != 0 { // 临时会话
if bot.Client.FindGroup(groupId) == nil {
log.Errorf("错误: 找不到群(%v)", groupId)
} else if code, ok := bot.tempMsgCache.Load(target); ok || groupID != 0 { // 临时会话
switch {
case groupID != 0 && bot.Client.FindGroup(groupID) == nil:
log.Errorf("错误: 找不到群(%v)", groupID)
id = -1
} else if groupId != 0 && !bot.Client.FindGroup(groupId).AdministratorOrOwner() {
log.Errorf("错误: 机器人在群(%v) 为非管理员或群主, 无法主动发起临时会话", groupId)
case groupID != 0 && !bot.Client.FindGroup(groupID).AdministratorOrOwner():
log.Errorf("错误: 机器人在群(%v) 为非管理员或群主, 无法主动发起临时会话", groupID)
id = -1
} else if groupId != 0 && bot.Client.FindGroup(groupId).FindMember(target) == nil {
log.Errorf("错误: 群员(%v) 不在 群(%v), 无法发起临时会话", target, groupId)
case groupID != 0 && bot.Client.FindGroup(groupID).FindMember(target) == nil:
log.Errorf("错误: 群员(%v) 不在 群(%v), 无法发起临时会话", target, groupID)
id = -1
} else {
if code != nil {
groupId = code.(int64)
default:
if code != nil && groupID == 0 {
groupID = code.(int64)
}
msg := bot.Client.SendTempMessage(groupId, target, m)
if msg != nil {
Expand Down

0 comments on commit 2f22784

Please sign in to comment.