1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-07 04:23:49 +08:00

add _send_group_notice

This commit is contained in:
wdvxdr 2020-09-06 11:53:31 +08:00
parent 5501c6192f
commit 6a0f44f6cc
3 changed files with 19 additions and 0 deletions

View File

@ -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 {

View File

@ -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))

View File

@ -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())
},