user9102437
user9102437

Reputation: 742

Telethon get channel participants without admin privilages

I am using telethon to handle a client on a custom app. What I would like to do is show the list of people subscribed to a certain telegram channel. Here is the setup:

from telethon import TelegramClient, events, sync

api_id = 8045283
api_hash = 'ad63dec5ee12u8baca534620d5b3d725' #not real btw
client = TelegramClient('name', api_id, api_hash)
await client.start()

After this I have tried functions like client.get_participants(channel), which returns the error:

ChatAdminRequiredError: Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group (caused by GetParticipantsRequest)

And also await client(GetFullChannelRequest(channel=channel)), which just doesn't have the required information.

I thought that this API was created exactly to create custom clients, but how is this possible if basic functionality cannot be implemented? Can anyone give a suggestion on how to achieve this? Maybe another way of getting such data?

Upvotes: 2

Views: 5430

Answers (2)

Kamal rohra
Kamal rohra

Reputation: 21

async for dialog in client.iter_dialogs():
        if  dialog.is_channel:
       
            print( dialog.entity.participants_count)

this is how you can get participants count without being an admin

Upvotes: 2

user9102437
user9102437

Reputation: 742

Okay, so I have actually confused terminology here. Telegram does not show the participant of the channel even on the official app (if you are not an admin), however, for Groups the get_participants method works great

Upvotes: 1

Related Questions