Is there a way to get a list of channels I’m a member of in Telegram (preferably Telegram Desktop)?
I may be able to come up with a solution using JS in the browser or even Selenium, but isn’t there a more ergonomic approach that would work in Telegram Desktop (like an API)?
If it matters I’m running Telegram as a snap application on Ubuntu 20.04.
2
Answers
You can use Python telethon library that allows you to act programmatically from your account.
Here is minimized code from Quick Start that allows to print all of your chats. There you can do whatever filtering or processing you need.
Even if you’ll want to write something there.
Well, the official Telegram Bot API does not have an option to get members of a channel. So using Telegrams MTPROTO to make your own client that will do this is the only legit way of retreiving this data.
As said, you could scrape the Telegram Web Version, but thats most likely to change some time soon which you’ll need to edit your scraper.
Telethon seems like a valid/stable solution, continue reading for a custom example script
If you just want to know what channels you’re member of, you can use the
dialog.entity
to check if the current one is of typeChannel
client.iter_dialogs()
to loop over each channelisinstance
to check if it’s aChannel
User
(chats)ChatForbidden
(Chats your kicked out off)Will output something like