mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
/get_group_list supported no_cache param.
This commit is contained in:
parent
a6bcd96415
commit
51696e8054
@ -34,8 +34,11 @@ func (bot *CQBot) CQGetFriendList() MSG {
|
||||
}
|
||||
|
||||
// https://cqhttp.cc/docs/4.15/#/API?id=get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8
|
||||
func (bot *CQBot) CQGetGroupList() MSG {
|
||||
func (bot *CQBot) CQGetGroupList(noCache bool) MSG {
|
||||
var gs []MSG
|
||||
if noCache {
|
||||
_ = bot.Client.ReloadGroupList()
|
||||
}
|
||||
for _, g := range bot.Client.GroupList {
|
||||
gs = append(gs, MSG{
|
||||
"group_id": g.Code,
|
||||
|
@ -209,7 +209,8 @@ func (s *httpServer) GetFriendList(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (s *httpServer) GetGroupList(c *gin.Context) {
|
||||
c.JSON(200, s.bot.CQGetGroupList())
|
||||
nc := getParamOrDefault(c, "no_cache", "false")
|
||||
c.JSON(200, s.bot.CQGetGroupList(nc == "true"))
|
||||
}
|
||||
|
||||
func (s *httpServer) GetGroupInfo(c *gin.Context) {
|
||||
|
@ -314,7 +314,7 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
|
||||
return bot.CQGetFriendList()
|
||||
},
|
||||
"get_group_list": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||
return bot.CQGetGroupList()
|
||||
return bot.CQGetGroupList(p.Get("no_cache").Bool())
|
||||
},
|
||||
"get_group_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||
return bot.CQGetGroupInfo(p.Get("group_id").Int())
|
||||
|
Loading…
x
Reference in New Issue
Block a user