mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-06-07 16:19:42 +08:00
fix #376.
This commit is contained in:
parent
d32f427328
commit
151e44628c
52
coolq/api.go
52
coolq/api.go
@ -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
|
// 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 {
|
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" {
|
if subType == "add" {
|
||||||
req, ok := bot.joinReqCache.Load(flag)
|
for _, req := range msgs.JoinRequests {
|
||||||
if !ok {
|
if strconv.FormatInt(req.RequestId, 10) == flag {
|
||||||
return Failed(100)
|
if req.Checked {
|
||||||
|
log.Errorf("处理群系统消息失败: 无法操作已处理的消息.")
|
||||||
|
return Failed(100)
|
||||||
|
}
|
||||||
|
if approve {
|
||||||
|
req.Accept()
|
||||||
|
} else {
|
||||||
|
req.Reject(false, reason)
|
||||||
|
}
|
||||||
|
return OK(nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bot.joinReqCache.Delete(flag)
|
} else {
|
||||||
if approve {
|
for _, req := range msgs.InvitedRequests {
|
||||||
req.(*client.UserJoinGroupRequest).Accept()
|
if strconv.FormatInt(req.RequestId, 10) == flag {
|
||||||
} else {
|
if req.Checked {
|
||||||
req.(*client.UserJoinGroupRequest).Reject(false, reason)
|
log.Errorf("处理群系统消息失败: 无法操作已处理的消息.")
|
||||||
|
return Failed(100)
|
||||||
|
}
|
||||||
|
if approve {
|
||||||
|
req.Accept()
|
||||||
|
} else {
|
||||||
|
req.Reject(false, reason)
|
||||||
|
}
|
||||||
|
return OK(nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return OK(nil)
|
|
||||||
}
|
|
||||||
req, ok := bot.invitedReqCache.Load(flag)
|
|
||||||
if ok {
|
|
||||||
bot.invitedReqCache.Delete(flag)
|
|
||||||
if approve {
|
|
||||||
req.(*client.GroupInvitedRequest).Accept()
|
|
||||||
} else {
|
|
||||||
req.(*client.GroupInvitedRequest).Reject(false, reason)
|
|
||||||
}
|
|
||||||
return OK(nil)
|
|
||||||
}
|
}
|
||||||
|
log.Errorf("处理群系统消息失败: 消息 %v 不存在.", flag)
|
||||||
return Failed(100)
|
return Failed(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
coolq/bot.go
12
coolq/bot.go
@ -23,13 +23,11 @@ import (
|
|||||||
type CQBot struct {
|
type CQBot struct {
|
||||||
Client *client.QQClient
|
Client *client.QQClient
|
||||||
|
|
||||||
events []func(MSG)
|
events []func(MSG)
|
||||||
db *leveldb.DB
|
db *leveldb.DB
|
||||||
friendReqCache sync.Map
|
friendReqCache sync.Map
|
||||||
invitedReqCache sync.Map
|
tempMsgCache sync.Map
|
||||||
joinReqCache sync.Map
|
oneWayMsgCache sync.Map
|
||||||
tempMsgCache sync.Map
|
|
||||||
oneWayMsgCache sync.Map
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type MSG map[string]interface{}
|
type MSG map[string]interface{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user