skip to Main Content

I am using Java library for Telegram Bots Api: https://github.com/rubenlagus/TelegramBots

The thing I’m wondering about — is it possible to detect when bot is removed from user contact list?
I would like to handle this event to delete user settings (such as language) from database, so next time user adds my bot, he can specify settings from scratch and not stucking on selected previously.

SOLUTION FOUND

I described my solution below.

3

Answers


  1. Chosen as BEST ANSWER

    Ok, I think I have found a possible solution.
    Hope, it will help to somebody.

    There's no need to handle bot removing, instead of this you can handle bot's restart, because first message bot receives everytime after user clears history or re-adds removed bot — is /start command. So receiveing /start command is a good point to reset previous settings and let user to specify them again.

    Also see the discussion above: Telegram Bot — reset user settings on chat removing / clearing


  2. This is not possible because you won’t receive a notification when user removes the bot. The only error you get is when you try to send a message to a user that has blocked the bot.

    Login or Signup to reply.
  3. While /start is working solution to recognize that user has restarted dialog with bot, now (September 2022) there is a way to get a disconnect message.

    ⚠️ I’m using another library and language, however shure that it’s an API feature, not depending on language (i’m using: C# nuget Telegram.Bot ver 18.0.0)

    When user click to "Stop and block bot":

    Telegram Bot Info menu, Stop and block bot

    Telegram sends an update message (Telegram.Bot.Types.Update) with ChatMemberUpdated info (MyChatMember field) – datails on person , see example:

    Telegram.Bot.Types.Update, Telegram.Bot.Types.ChatMemberUpdated example

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search