windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.
Other
256 stars 116 forks source link

Last seen #271

Closed PeterHunt closed 1 year ago

PeterHunt commented 1 year ago

Hello,

Is there any way of retrieving a users last seen timestamp?

Kind regards,

Peter Hunt

windkh commented 1 year ago

Good question. Let me think about it ...

PeterHunt commented 1 year ago

Good question. Let me think about it ...

That would be great! I have a BOT which currently has about 1800 users but I noticed that several are not inactive no more and would like to kick them from the BOT periodically. They already are being removed when they delete or block the BOT themselve but not upon inactivity.

Thanks for looking into it :)

windkh commented 1 year ago

@PeterHunt I did some research and in the end i believe that the BOT API does not support anything like that: see https://stackoverflow.com/questions/33844290/how-to-get-telegram-channel-users-list-with-telegram-bot-api

The BOT only receives messages from channels and along the message you get additional information like the user id or chat id... but there is nothing that a bot can call to resolve a username from id or statistics like "last seen".

The only chance you have is maintaining these statistics on your own in your flow by storing the user id (with channel id) together with the date in a database and to the logic there. This will only work from the time the user entered the channel.

windkh commented 1 year ago

see also https://stackoverflow.com/questions/38131042/getting-the-users-last-seen-from-a-telegram-bot

windkh commented 1 year ago

I will keep this in my mind and will implement it as soon as the BOT API will support it.

PeterHunt commented 1 year ago

Thanks for the research and your feedback! :)