From 2897a58214af76357aa36fc3b32ecbf8e123410b Mon Sep 17 00:00:00 2001 From: amtoaer Date: Tue, 6 May 2025 23:37:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20set=20group=20?= =?UTF-8?q?reaction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/api.go | 15 +++++++++++++++ modules/api/api.go | 10 +++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/coolq/api.go b/coolq/api.go index d6361d004..8957849f8 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -1411,6 +1411,21 @@ func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) global.M return Failed(100, "GROUP_NOT_FOUND", "群聊不存在") } +// CQSetGroupReaction 扩展API-设置群消息表态 +// +// @route(set_group_reaction) +func (bot *CQBot) CQSetGroupReaction(messageID int32, emojiID string, isAdd bool) global.MSG { + msg, err := db.GetGroupMessageByGlobalID(messageID) + if err != nil { + return Failed(100, "MESSAGE_NOT_FOUND", "消息不存在") + } + if err := bot.Client.SetGroupReaction(uint32(msg.GroupCode), uint32(msg.Attribute.MessageSeq), emojiID, isAdd); err != nil { + log.Warnf("发送群表态失败: %v", err) + return Failed(100, "SEND_GROUP_REACTIONS_ERROR", err.Error()) + } + return OK(nil) +} + // CQSetGroupAnonymousBan 群组匿名用户禁言 // // https://git.io/Jtz1p diff --git a/modules/api/api.go b/modules/api/api.go index bcda0853d..726681b70 100644 --- a/modules/api/api.go +++ b/modules/api/api.go @@ -256,6 +256,14 @@ func (c *Caller) call(action string, spec *onebot.Spec, p Getter) global.MSG { p1 := p.Get("file").String() p2 := p.Get("cache").String() return c.bot.CQSetGroupPortrait(p0, p1, p2) + case "set_group_reaction": + p0 := int32(p.Get("message_id").Int()) + p1 := p.Get("emoji_id").String() + p2 := true + if pt := p.Get("is_add"); pt.Exists() { + p2 = pt.Bool() + } + return c.bot.CQSetGroupReaction(p0, p1, p2) case "set_group_special_title": p0 := p.Get("group_id").Int() p1 := p.Get("user_id").Int() @@ -279,6 +287,6 @@ func (c *Caller) call(action string, spec *onebot.Spec, p Getter) global.MSG { p1 := p.Get("file").String() p2 := p.Get("name").String() return c.bot.CQUploadPrivateFile(p0, p1, p2) - } +} return coolq.Failed(404, "API_NOT_FOUND", "API不存在") } From 3f74f651d88c046c2d7631f956645d22a01fa5a9 Mon Sep 17 00:00:00 2001 From: amtoaer Date: Wed, 7 May 2025 00:45:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=E4=BD=BF=E7=94=A8=20go=20generate?= =?UTF-8?q?=20=E7=94=9F=E6=88=90=20api.go=E3=80=81supported.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/api.go | 1 + modules/api/api.go | 2 +- pkg/onebot/supported.go | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/coolq/api.go b/coolq/api.go index 8957849f8..d40c80a9d 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -1414,6 +1414,7 @@ func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) global.M // CQSetGroupReaction 扩展API-设置群消息表态 // // @route(set_group_reaction) +// @default(is_add=true) func (bot *CQBot) CQSetGroupReaction(messageID int32, emojiID string, isAdd bool) global.MSG { msg, err := db.GetGroupMessageByGlobalID(messageID) if err != nil { diff --git a/modules/api/api.go b/modules/api/api.go index 726681b70..5d77b211e 100644 --- a/modules/api/api.go +++ b/modules/api/api.go @@ -287,6 +287,6 @@ func (c *Caller) call(action string, spec *onebot.Spec, p Getter) global.MSG { p1 := p.Get("file").String() p2 := p.Get("name").String() return c.bot.CQUploadPrivateFile(p0, p1, p2) -} + } return coolq.Failed(404, "API_NOT_FOUND", "API不存在") } diff --git a/pkg/onebot/supported.go b/pkg/onebot/supported.go index 3ceaa0e72..69727ad6d 100644 --- a/pkg/onebot/supported.go +++ b/pkg/onebot/supported.go @@ -62,6 +62,7 @@ var supportedV11 = []string{ "set_group_leave", "set_group_name", "set_group_portrait", + "set_group_reaction", "set_group_special_title", "set_group_whole_ban", "upload_group_file", @@ -118,6 +119,7 @@ var supportedV12 = []string{ "set_group_leave", "set_group_name", "set_group_portrait", + "set_group_reaction", "set_group_special_title", "set_group_whole_ban", "upload_group_file",