1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 12:03:50 +08:00

feat: get_guild_meta_by_guest api

This commit is contained in:
Mrs4s 2021-11-07 16:28:27 +08:00
parent 0ea826f0a2
commit f316278c57
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7
2 changed files with 26 additions and 1 deletions

View File

@ -65,7 +65,7 @@ func (bot *CQBot) CQGetGuildServiceProfile() global.MSG {
func (bot *CQBot) CQGetGuildList() global.MSG { func (bot *CQBot) CQGetGuildList() global.MSG {
fs := make([]global.MSG, 0, len(bot.Client.GuildService.Guilds)) fs := make([]global.MSG, 0, len(bot.Client.GuildService.Guilds))
for _, info := range bot.Client.GuildService.Guilds { for _, info := range bot.Client.GuildService.Guilds {
channels := make([]global.MSG, len(info.Channels)) channels := make([]global.MSG, 0, len(info.Channels))
for _, channel := range info.Channels { for _, channel := range info.Channels {
channels = append(channels, global.MSG{ channels = append(channels, global.MSG{
"channel_id": channel.ChannelId, "channel_id": channel.ChannelId,
@ -83,6 +83,28 @@ func (bot *CQBot) CQGetGuildList() global.MSG {
return OK(fs) return OK(fs)
} }
// CQGetGuildMetaByGuest 通过访客权限获取频道元数据
// @route(get_guild_meta_by_guest)
// @rename(guildId->guild_id)
func (bot *CQBot) CQGetGuildMetaByGuest(guildId int64) global.MSG {
meta, err := bot.Client.GuildService.FetchGuestGuild(uint64(guildId))
if err != nil {
log.Errorf("获取频道元数据时出现错误: %v", err)
return Failed(100, "API_ERROR", err.Error())
}
return OK(global.MSG{
"guild_id": meta.GuildId,
"guild_name": meta.GuildName,
"guild_profile": meta.GuildProfile,
"create_time": meta.CreateTime,
"max_member_count": meta.MaxMemberCount,
"max_robot_count": meta.MaxRobotCount,
"max_admin_count": meta.MaxAdminCount,
"member_count": meta.MemberCount,
"owner_id": meta.OwnerId,
})
}
// CQGetFriendList 获取好友列表 // CQGetFriendList 获取好友列表
// //
// https://git.io/Jtz1L // https://git.io/Jtz1L

View File

@ -125,6 +125,9 @@ func (c *Caller) call(action string, p Getter) global.MSG {
return c.bot.CQGetGroupSystemMessages() return c.bot.CQGetGroupSystemMessages()
case "get_guild_list": case "get_guild_list":
return c.bot.CQGetGuildList() return c.bot.CQGetGuildList()
case "get_guild_meta_by_guest":
p0 := p.Get("guild_id").Int()
return c.bot.CQGetGuildMetaByGuest(p0)
case "get_guild_service_profile": case "get_guild_service_profile":
return c.bot.CQGetGuildServiceProfile() return c.bot.CQGetGuildServiceProfile()
case "get_image": case "get_image":