From 4e7eb32a0a5596e59c4a07badf51d851932f0b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 12 Oct 2023 00:36:23 +0900 Subject: [PATCH] finish announce --- openapi_announces.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 openapi_announces.go diff --git a/openapi_announces.go b/openapi_announces.go new file mode 100644 index 0000000..1b2360e --- /dev/null +++ b/openapi_announces.go @@ -0,0 +1,38 @@ +package nano + +// Announces 公告对象 +// +// https://bot.q.qq.com/wiki/develop/api/openapi/announces/model.html#announces +type Announces struct { + GuildID string `json:"guild_id,omitempty"` + ChannelID string `json:"channel_id,omitempty"` + MessageID string `json:"message_id,omitempty"` + AnnouncesType uint32 `json:"announces_type,omitempty"` // 公告类别 0:成员公告 1:欢迎公告,默认成员公告 + RecommendChannels []RecommendChannel `json:"recommend_channels,omitempty"` +} + +// RecommendChannel 推荐子频道对象 +// +// https://bot.q.qq.com/wiki/develop/api/openapi/announces/model.html#recommendchannel +type RecommendChannel struct { + ChannelID string `json:"channel_id"` + Introduce string `json:"introduce"` +} + +// PostAnnounceInGuild 创建频道全局公告,公告类型分为 消息类型的频道公告 和 推荐子频道类型的频道公告 +// +// https://bot.q.qq.com/wiki/develop/api/openapi/announces/post_guild_announces.html +// +// 会重写 content 为返回值 +func (bot *Bot) PostAnnounceInGuild(id string, content *Announces) error { + return bot.PostOpenAPI("/guilds/"+id+"/announces", "", content, WriteBodyFromJSON(content)) +} + +// DeleteAnnounceInGuild 删除频道 guild_id 下指定 message_id 的全局公告 +// +// https://bot.q.qq.com/wiki/develop/api/openapi/announces/delete_guild_announces.html +// +// message_id 有值时,会校验 message_id 合法性,若不校验校验 message_id,请将 message_id 设置为 all +func (bot *Bot) DeleteAnnounceInGuild(guildid, messageid string) error { + return bot.DeleteOpenAPI("/guilds/"+guildid+"/announces/"+messageid, "", nil) +}