mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 19:43:49 +08:00
update.
This commit is contained in:
parent
e5718fc47c
commit
eca396afb3
28
coolq/api.go
28
coolq/api.go
@ -68,20 +68,7 @@ func (bot *CQBot) CQGetGroupInfo(groupId int64) MSG {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// https://cqhttp.cc/docs/4.15/#/API?id=get_group_member_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8
|
// https://cqhttp.cc/docs/4.15/#/API?id=get_group_member_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8
|
||||||
func (bot *CQBot) CQGetGroupMemberList(groupId int64) MSG {
|
func (bot *CQBot) CQGetGroupMemberList(groupId int64, noCache bool) MSG {
|
||||||
group := bot.Client.FindGroup(groupId)
|
|
||||||
if group == nil {
|
|
||||||
return Failed(100)
|
|
||||||
}
|
|
||||||
members := make([]MSG, 0)
|
|
||||||
for _, m := range group.Members {
|
|
||||||
members = append(members, convertGroupMemberInfo(groupId, m))
|
|
||||||
}
|
|
||||||
return OK(members)
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://cqhttp.cc/docs/4.15/#/API?id=get_group_member_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF
|
|
||||||
func (bot *CQBot) CQGetGroupMemberInfo(groupId, userId int64, noCache bool) MSG {
|
|
||||||
group := bot.Client.FindGroup(groupId)
|
group := bot.Client.FindGroup(groupId)
|
||||||
if group == nil {
|
if group == nil {
|
||||||
return Failed(100)
|
return Failed(100)
|
||||||
@ -94,6 +81,19 @@ func (bot *CQBot) CQGetGroupMemberInfo(groupId, userId int64, noCache bool) MSG
|
|||||||
}
|
}
|
||||||
group.Members = t
|
group.Members = t
|
||||||
}
|
}
|
||||||
|
members := make([]MSG, 0)
|
||||||
|
for _, m := range group.Members {
|
||||||
|
members = append(members, convertGroupMemberInfo(groupId, m))
|
||||||
|
}
|
||||||
|
return OK(members)
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://cqhttp.cc/docs/4.15/#/API?id=get_group_member_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF
|
||||||
|
func (bot *CQBot) CQGetGroupMemberInfo(groupId, userId int64) MSG {
|
||||||
|
group := bot.Client.FindGroup(groupId)
|
||||||
|
if group == nil {
|
||||||
|
return Failed(100)
|
||||||
|
}
|
||||||
member := group.FindMember(userId)
|
member := group.FindMember(userId)
|
||||||
if member == nil {
|
if member == nil {
|
||||||
return Failed(102)
|
return Failed(102)
|
||||||
|
@ -233,14 +233,14 @@ func (s *httpServer) GetGroupInfo(c *gin.Context) {
|
|||||||
|
|
||||||
func (s *httpServer) GetGroupMemberList(c *gin.Context) {
|
func (s *httpServer) GetGroupMemberList(c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQGetGroupMemberList(gid))
|
nc := getParamOrDefault(c, "no_cache", "false")
|
||||||
|
c.JSON(200, s.bot.CQGetGroupMemberList(gid, nc == "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupMemberInfo(c *gin.Context) {
|
func (s *httpServer) GetGroupMemberInfo(c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
nc := getParamOrDefault(c, "no_cache", "false")
|
c.JSON(200, s.bot.CQGetGroupMemberInfo(gid, uid))
|
||||||
c.JSON(200, s.bot.CQGetGroupMemberInfo(gid, uid, nc == "true"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SendMessage(c *gin.Context) {
|
func (s *httpServer) SendMessage(c *gin.Context) {
|
||||||
|
@ -397,12 +397,11 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
|
|||||||
return bot.CQGetGroupInfo(p.Get("group_id").Int())
|
return bot.CQGetGroupInfo(p.Get("group_id").Int())
|
||||||
},
|
},
|
||||||
"get_group_member_list": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"get_group_member_list": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQGetGroupMemberList(p.Get("group_id").Int())
|
return bot.CQGetGroupMemberList(p.Get("group_id").Int(), p.Get("no_cache").Bool())
|
||||||
},
|
},
|
||||||
"get_group_member_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"get_group_member_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQGetGroupMemberInfo(
|
return bot.CQGetGroupMemberInfo(
|
||||||
p.Get("group_id").Int(), p.Get("user_id").Int(),
|
p.Get("group_id").Int(), p.Get("user_id").Int(),
|
||||||
p.Get("no_cache").Bool(),
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
"send_msg": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"send_msg": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user