diff --git a/coolq/api.go b/coolq/api.go index f9ecde26..3670e3d4 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -304,6 +304,14 @@ func (bot *CQBot) CQSetGroupName(groupId int64, name string) MSG { return Failed(100) } +func (bot *CQBot) CQSetGroupMemo(groupId int64, msg string) MSG { + if g := bot.Client.FindGroup(groupId); g != nil { + g.UpdateMemo(msg) + return OK(nil) + } + return Failed(100) +} + // https://cqhttp.cc/docs/4.15/#/API?id=set_group_kick-%E7%BE%A4%E7%BB%84%E8%B8%A2%E4%BA%BA func (bot *CQBot) CQSetGroupKick(groupId, userId int64, msg string) MSG { if g := bot.Client.FindGroup(groupId); g != nil { diff --git a/server/http.go b/server/http.go index aa4d591d..64b75993 100644 --- a/server/http.go +++ b/server/http.go @@ -131,6 +131,9 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) { s.engine.Any("/set_group_name", s.SetGroupName) s.engine.Any("/set_group_name_async", s.SetGroupName) + s.engine.Any("/_send_group_notice", s.SendGroupNotice) + s.engine.Any("/_send_group_notice_async", s.SendGroupNotice) + s.engine.Any("/set_group_leave", s.SetGroupLeave) s.engine.Any("/set_group_leave_async", s.SetGroupLeave) @@ -353,6 +356,11 @@ func (s *httpServer) SetGroupName(c *gin.Context) { c.JSON(200, s.bot.CQSetGroupName(gid, getParam(c, "group_name"))) } +func (s *httpServer) SendGroupNotice(c *gin.Context) { + gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64) + c.JSON(200, s.bot.CQSetGroupMemo(gid, getParam(c, "content"))) +} + func (s *httpServer) SetGroupLeave(c *gin.Context) { gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64) c.JSON(200, s.bot.CQSetGroupLeave(gid)) diff --git a/server/websocket.go b/server/websocket.go index 9f80ee41..20986a49 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -479,6 +479,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{ "set_group_name": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG { return bot.CQSetGroupName(p.Get("group_id").Int(), p.Get("group_name").Str) }, + "_send_group_notice": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG { + return bot.CQSetGroupMemo(p.Get("group_id").Int(), p.Get("content").Str) + }, "set_group_leave": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG { return bot.CQSetGroupLeave(p.Get("group_id").Int()) },