diff --git a/coolq/api.go b/coolq/api.go index d6361d004..d40c80a9d 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -1411,6 +1411,22 @@ func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) global.M return Failed(100, "GROUP_NOT_FOUND", "群聊不存在") } +// 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 { + 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..5d77b211e 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() 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",