Search code examples
pythontelegramtelebot

Get telegram subscriber username via telegram admin bot


I have my own telegram channel and a telegram bot which is also a channel administrator.

  1. How can I get the username of all my subscribers using python(telebot)?
  2. And is it possible to find out by which link the subscriber subscribed to the channel using python(telebot)?

Solution

  • I did not find how to do it with a telebot, but with a pyrogram

    from pyrogram import Client
    
    TARGET = -100....
    api_id = 91...
    api_hash = "2f01....."
    link = 'https://t.me/+PP.........'
    
    app = Client("my_account", api_id, api_hash)
    async def main():
        async with app:
            async for event in app.get_chat_invite_link_joiners(chat_id=TARGET, invite_link=link):