Commit 51696e80 authored by Mrs4s's avatar Mrs4s

/get_group_list supported no_cache param.

parent a6bcd964
...@@ -34,8 +34,11 @@ func (bot *CQBot) CQGetFriendList() MSG { ...@@ -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 // 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 var gs []MSG
if noCache {
_ = bot.Client.ReloadGroupList()
}
for _, g := range bot.Client.GroupList { for _, g := range bot.Client.GroupList {
gs = append(gs, MSG{ gs = append(gs, MSG{
"group_id": g.Code, "group_id": g.Code,
......
...@@ -209,7 +209,8 @@ func (s *httpServer) GetFriendList(c *gin.Context) { ...@@ -209,7 +209,8 @@ func (s *httpServer) GetFriendList(c *gin.Context) {
} }
func (s *httpServer) GetGroupList(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) { func (s *httpServer) GetGroupInfo(c *gin.Context) {
......
...@@ -314,7 +314,7 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{ ...@@ -314,7 +314,7 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
return bot.CQGetFriendList() return bot.CQGetFriendList()
}, },
"get_group_list": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG { "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 { "get_group_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
return bot.CQGetGroupInfo(p.Get("group_id").Int()) return bot.CQGetGroupInfo(p.Get("group_id").Int())
......
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