diff --git a/coolq/api.go b/coolq/api.go index fe64af5..d49313e 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -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, diff --git a/server/http.go b/server/http.go index 6bac8bf..6a27bb0 100644 --- a/server/http.go +++ b/server/http.go @@ -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) { diff --git a/server/websocket.go b/server/websocket.go index f127026..45a4f3c 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -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())