Пример #1
0
        public async Task AdminList()
        {
            using var operation = Operation.Begin("Ping command handler");

            await SendMessageTextAsync("Sedang mengambil data..");

            _logger.LogDebug("Loading chat admin on '{ChatId}'..", ChatId);

            var administrators = await _privilegeService.GetChatAdministratorsAsync(ChatId);

            var creatorGroup = administrators.FirstOrDefault(member => member.Status == ChatMemberStatus.Creator);
            var adminsGroup  = administrators.Where(member => member.Status != ChatMemberStatus.Creator).ToList();

            _logger.LogDebug("Parsing admin lists..");
            var htmlMessage = new HtmlString();

            if (creatorGroup != null)
            {
                htmlMessage.Bold("👤 Creator").Br();
                htmlMessage.UserMention(creatorGroup.User).Br().Br();
            }

            htmlMessage.Bold("👥 Administrators").Br();

            var lastItem = adminsGroup.Last();

            foreach (var admin in adminsGroup)
            {
                htmlMessage.UserMention(admin.User);

                if (admin != lastItem)
                {
                    htmlMessage.Br();
                }
            }

            await EditMessageTextAsync(htmlMessage);

            operation.Complete();
        }