protected async Task <bool> IsBotAdmin(Message message)
        {
            if (message.Chat.Type == ChatType.Private)
            {
                return(true);
            }

            var bot = await Client.GetMeAsync();

            var chatAdministrators = await Client.GetChatAdministratorsAsync(message.Chat.Id);

            return(chatAdministrators.Any(v => v.User.Id == bot.Id));
        }
示例#2
0
    public static async Task <bool> IsUserAdmin(ITelegramBotClientWrapper client, Message message, User user = null)
    {
        if (message.Chat.Type == ChatType.Private)
        {
            return(true);
        }

        var chatAdministrators = await client.GetChatAdministratorsAsync(message.Chat.Id);

        var currentUserId = user?.Id ?? message.From.Id;

        return(chatAdministrators.Any(v => v.User.Id == currentUserId));
    }