Telethon: Getting number of chat/channel members

Created on 10 Feb 2018  路  2Comments  路  Source: LonamiWebs/Telethon

All I want to do is say:

number_of_members = xyz(some_entity)

and get an integer back.

There's a method in the Telegram Bot API GetChatMembers(), but I don't think it's in the client API. The closest I see in the Telethon documentation is here:

http://telethon.readthedocs.io/en/latest/extra/examples/chats-and-channels.html?highlight=participant%20count

But that wants to get a list of the members. I just need a count. Is there something easy?

Thanks, Lee

Most helpful comment

`
from telethon import client
from telethon.sync import TelegramClient
from telethon.tl.functions.channels import GetFullChannelRequest

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

channel_connect = self.client.get_entity(channel_name)
channel_full_info = client(GetFullChannelRequest(channel=channel_connect))
print(channel_full_info.full_chat.participants_count)`

All 2 comments

Get the full channel.

`
from telethon import client
from telethon.sync import TelegramClient
from telethon.tl.functions.channels import GetFullChannelRequest

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

channel_connect = self.client.get_entity(channel_name)
channel_full_info = client(GetFullChannelRequest(channel=channel_connect))
print(channel_full_info.full_chat.participants_count)`

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adv-zl picture adv-zl  路  3Comments

amir3code picture amir3code  路  6Comments

Fleyderer picture Fleyderer  路  3Comments

pazis picture pazis  路  5Comments

saharokk picture saharokk  路  3Comments