Как с помощью API получить количество участников канала Телеграмм?

Всем привет! Помогите пожалуйста найти команду, как с помощью API в Телеграме можно получить значение количества подписчиков на канале, на который я подписан. Заранее благодарен!
  • Вопрос задан
  • 5938 просмотров
Пригласить эксперта
Ответы на вопрос 3
pavlyk
@pavlyk
1С программист
Ответ написан
Комментировать
@dydoser
палю годноту: tgspambot.tk
только осторожно, меня за его использование забанили
Ответ написан
Комментировать
EXL
@EXL
Энтузиаст
С помощью Python 3 очень просто:

from time import sleep

from telethon import TelegramClient

from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsSearch

api_id = <app_id>
api_hash = '<app_hash>'
phone = '+88005553535'
group_link = 't.me/joinchat/<group_hash>'

client = TelegramClient('session_name', api_id, api_hash)
client.connect()
channel = client.get_entity(group_link)

if not client.is_user_authorized():
    client.send_code_request(phone)
    client.sign_in(phone, input('Please Enter the verification code: '))

def get_users(a_channel):
    offset = 0
    limit = 100
    all_participants = []
    while True:
        participants = client.invoke(GetParticipantsRequest(
            a_channel, ChannelParticipantsSearch(''), offset, limit, hash=0
        ))
        if not participants.users:
            break
        all_participants.extend(participants.users)
        offset += len(participants.users)
        sleep(1)
    return all_participants

def print_users(a_users):
    for user in a_users:
        print(user.username)

print_users(get_users(channel))


Подробнее:
https://github.com/LonamiWebs/Telethon
https://github.com/LonamiWebs/Telethon/wiki/Retrie...
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы