-1

I've seen some bot creators before with options to extract all members of bot who interacted (or started) bot before. but I can't find any method in telegram docs for extract users. Do you know any method for extract users of bot in any library or something?

I asked ChatGPT but he gives me a code for extract chat users:

async def get_users(client, message):
    if message.text == "/users":
        # get all users who have ever interacted with the bot
        async for member in app.iter_chat_members(chat_id=message.chat.id):
            user = member.user
            if user.is_bot:
                continue
            if user.status == 'restricted' or user.status == 'kicked':
                continue

How can I get UserID from user who started my bot before if I didn't save it?

there is any method for extract users of bot in any library or something?

1 Answers1

0

How can I get UserID from user who started my bot before if I didn't save it?

You cant!

After you've passed an offset to the getUpdates call to remove any messages from the update queue, they're gone. Reff

There is no way to ask Telegram for a list of chat's that ever talked with your bot.


The only way of doing this is by a custom implementation where you save each chat id somewhere to recall later.

0stone0
  • 34,288
  • 4
  • 39
  • 64
  • I've seen before some bot creators extracts users of bots from token – Hosein Erish Feb 17 '23 at 16:43
  • What? Please clarify! They use the bot token to get a list of users? – 0stone0 Feb 17 '23 at 16:43
  • yes they did. you send them bot token for create a new bot and they have an option for extraxt all members for sending message to all , summeries and more – Hosein Erish Feb 17 '23 at 16:47
  • Oke well, if you know it better, why do you ask here? Not sure what your looking for. Telegram does not provide an BOT API endpoint were you can see what user ever talked to the bot. – 0stone0 Feb 17 '23 at 16:48
  • I don't know how he did it. I know telegram does not have any option in BOT API for extract bot members but some people do it . I asked from creator of that bot and he didn't help me just said check Madline Proto update methods and I didn't get any answer – Hosein Erish Feb 17 '23 at 16:52
  • You didn;t even mention Madline in your question. But if you know that there is no BOT API route for this. What are you looking for in an aswer? – 0stone0 Feb 17 '23 at 17:00
  • Bro Madeline pyrogram telethon all of them using same CLI. And my topic is not just for web API I'm talking about mtproto CLI – Hosein Erish Feb 18 '23 at 07:31