8

When I chat with a telegram user, I can see for each user their "last seen" - when they last connected to Telegram (even if I haven't chatted with them for a while).

Is there a way to query for this information via the bot API? I haven't found a way to access it.

ripper234
  • 222,824
  • 274
  • 634
  • 905
  • Do you mean so as to see when they were last online even if they have their privacy setting set to hide such wherein all we see as a result is "last seen recently?" I'm trying to catch a liar myself and would like to see how to see when the person was last online, but I never can. – Private Name Oct 07 '20 at 09:38

4 Answers4

15

It's not possible with the Telegram Bot API. But it's possible with Telegram API which allows you to build your own customized Telegram clients, and have other methods like read messages, or status (limited by the target users' privacy settings, of course).

After generate an hash to authenticate your API client on my telegram, you can use a library like Telegram-MTProto to call contacts.getStatuses which return an array of ContactStatus and know if user is online or offline.

const getStatuses = async () => {
    const statuses = await telegram('contacts.getStatuses', {})
    // Check online status
    if(statuses[0].status._ === 'userStatusOnline')
        // Online
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Xamrix
  • 452
  • 3
  • 12
  • Hello, About this telegram API, do they have some documentation for Python or can you point towards Python tutorials of Telegram API, I want to use this getStatuses, but can't get it right – Owais Ch Oct 03 '21 at 16:23
10

That's currently not possible with the Telegram Bot API.

Maak
  • 4,720
  • 3
  • 28
  • 39
  • 1
    It's no longer exact, read my answer. https://stackoverflow.com/a/48506509/3139417 – Xamrix Oct 08 '18 at 10:15
  • 1
    The questions was targeted at the Telegram Bot API, therefore the answer is still correct. – Maak Oct 08 '18 at 10:19
-1

In plus messenger , using bot login , relative last seen is shown.

Maybe you could ask them in their Official support group: https://t.me/plusmsgrchat (I'm blocked)

Smart Manoj
  • 5,230
  • 4
  • 34
  • 59
-2

https://core.telegram.org/bots#4-how-are-bots-different-from-humans

Bots have no online status and no last seen timestamps, the interface shows the label ‘bot’ instead.

Giac
  • 462
  • 6
  • 21
  • 1
    That's not really what I asked - not how to get the status of a bot, but how, as a bot, to get the "last seen" of the human I'm interacting with. – ripper234 Jul 08 '16 at 12:11