Commit 151e4462 authored by Mrs4s's avatar Mrs4s

fix #376.

parent d32f4273
......@@ -384,29 +384,43 @@ func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) MSG {
// https://cqhttp.cc/docs/4.15/#/API?id=set_group_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%EF%BC%8F%E9%82%80%E8%AF%B7
func (bot *CQBot) CQProcessGroupRequest(flag, subType, reason string, approve bool) MSG {
msgs, err := bot.Client.GetGroupSystemMessages()
if err != nil {
log.Errorf("获取群系统消息失败: %v", err)
return Failed(100)
}
if subType == "add" {
req, ok := bot.joinReqCache.Load(flag)
if !ok {
for _, req := range msgs.JoinRequests {
if strconv.FormatInt(req.RequestId, 10) == flag {
if req.Checked {
log.Errorf("处理群系统消息失败: 无法操作已处理的消息.")
return Failed(100)
}
bot.joinReqCache.Delete(flag)
if approve {
req.(*client.UserJoinGroupRequest).Accept()
req.Accept()
} else {
req.(*client.UserJoinGroupRequest).Reject(false, reason)
req.Reject(false, reason)
}
return OK(nil)
}
req, ok := bot.invitedReqCache.Load(flag)
if ok {
bot.invitedReqCache.Delete(flag)
}
} else {
for _, req := range msgs.InvitedRequests {
if strconv.FormatInt(req.RequestId, 10) == flag {
if req.Checked {
log.Errorf("处理群系统消息失败: 无法操作已处理的消息.")
return Failed(100)
}
if approve {
req.(*client.GroupInvitedRequest).Accept()
req.Accept()
} else {
req.(*client.GroupInvitedRequest).Reject(false, reason)
req.Reject(false, reason)
}
return OK(nil)
}
}
}
log.Errorf("处理群系统消息失败: 消息 %v 不存在.", flag)
return Failed(100)
}
......
......@@ -26,8 +26,6 @@ type CQBot struct {
events []func(MSG)
db *leveldb.DB
friendReqCache sync.Map
invitedReqCache sync.Map
joinReqCache sync.Map
tempMsgCache sync.Map
oneWayMsgCache sync.Map
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment