From 0ea826f0a20c3e28b26d459ccab723eca0561b1c Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Sun, 7 Nov 2021 16:20:57 +0800 Subject: [PATCH] feat: get_guild_list api --- coolq/api.go | 23 +++++++++++++++++++++++ modules/api/api.go | 2 ++ 2 files changed, 25 insertions(+) diff --git a/coolq/api.go b/coolq/api.go index 1dbef38..60d329c 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -60,6 +60,29 @@ func (bot *CQBot) CQGetGuildServiceProfile() global.MSG { }) } +// CQGetGuildList 获取已加入的频道列表 +// @route(get_guild_list) +func (bot *CQBot) CQGetGuildList() global.MSG { + fs := make([]global.MSG, 0, len(bot.Client.GuildService.Guilds)) + for _, info := range bot.Client.GuildService.Guilds { + channels := make([]global.MSG, len(info.Channels)) + for _, channel := range info.Channels { + channels = append(channels, global.MSG{ + "channel_id": channel.ChannelId, + "channel_name": channel.ChannelName, + "channel_type": channel.ChannelType, + }) + } + fs = append(fs, global.MSG{ + "guild_id": info.GuildId, + "guild_name": info.GuildName, + "guild_display_id": info.GuildCode, + "channels": channels, + }) + } + return OK(fs) +} + // CQGetFriendList 获取好友列表 // // https://git.io/Jtz1L diff --git a/modules/api/api.go b/modules/api/api.go index 9847d2a..b20a48a 100644 --- a/modules/api/api.go +++ b/modules/api/api.go @@ -123,6 +123,8 @@ func (c *Caller) call(action string, p Getter) global.MSG { return c.bot.CQGetGroupRootFiles(p0) case "get_group_system_msg": return c.bot.CQGetGroupSystemMessages() + case "get_guild_list": + return c.bot.CQGetGuildList() case "get_guild_service_profile": return c.bot.CQGetGuildServiceProfile() case "get_image":