예제 #1
0
    public override async Task HandleAsync(IUpdateContext context, UpdateDelegate next, string[] args)
    {
        await _telegramService.AddUpdateContext(context);

        var channelId = _telegramService.ReducedChatId;

        var allMembers = await _wTelegramApiService.GetAllParticipants(channelId);

        var allMemberStr = allMembers.users.Select((participant, i) => {
            var user = (User)participant.Value;

            return(user.id.GetMention());
        }).JoinStr("");

        await _telegramService.SendTextMessageAsync($"Hai {allMembers.participants.Count()} orang");

        // allMemberStr.SplitInParts(4000).ForEach(async s => { await _telegramService.SendTextMessageAsync(s); });
    }
예제 #2
0
        public async Task CmdAllMember()
        {
            var update = RawUpdate.ToJson(indented: true);

            // var client = await _iWTelegramApiService.CreateClient();
            // client.CollectAccessHash = true;
            // var accessHash = client.GetAccessHashFor<Channel>(ChatId);
            // var chats = await client.Messages_GetAllChats(null);
            // var chat = chats.chats.Values.First(x => x.ID == cid);
            // var channel = (Channel) chats.chats[cid];
            // var channels = await client.Channels_GetParticipants(channel, null, 0, 1000, 0);
            // var cid = ChatId.ReduceChatId();
            // var channels = await client.Channels_GetParticipants(new InputChannel()
            // {
            // access_hash =  client.GetAccessHashFor<Channel>(cid),
            // channel_id = cid
            // }, null, 0, 1000, 0);

            // var fullChat = await client.Messages_GetFullChat(chat.ID);
            // var fullChat = await client.Channels_GetFullChannel(new InputChannel()
            // {
            // access_hash = client.GetAccessHashFor<Channel>(cid),
            // channel_id = cid
            // });

            // var users = fullChat.users.Take(200);

            var channels = await _iWTelegramApiService.GetAllParticipants(ChatId);

            var htmlStr = new HtmlString();

            foreach (var(id, userBase) in channels.users)
            // foreach (var user in channels.users)
            {
                var user = (User)userBase;
                // htmlStr.Text(user.ID.ToString()).Text(" - ").Text(u.first_name).Br();
                // var u = (User)user;
                htmlStr.Text(user.id.ToString()).Text(" - ").Text(user.first_name).Br();
            }

            htmlStr.Br();

            await SendMessageTextAsync(htmlStr);
        }