yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.31k stars 1.51k forks source link

The getChatMember() method suddenly stops seeing one of the chat users #935

Closed Alexal3 closed 2 years ago

Alexal3 commented 2 years ago

Bug Report

The getChatMember() method suddenly stops seeing one of the chat users. Very unusual bug. Please read to the end.

There is a Telegram bot (https://github.com/Alexal3/bolt-meter-bot). It has a /stats command. Its code is located in the file https://github.com/Alexal3/bolt-meter-bot/blob/main/src/index.js. At the time of writing this bug report, the most recent commit is https://github.com/Alexal3/bolt-meter-bot/commit/9257cce3d2038eda7e27ed52abec40e2064a9b4a . This command sometimes stops working for some chat. Right now, for example, the command does not work for the public chat https://t.me/alexal_blog_chat . According to the logs, the problem is in the node-telegram-bot-api library or in the Telegram API, and not in my code.

Now I'll tell you more. I launched the bot on the server and added it to the chat. The /stats command worked. Then after a while it stopped working. In the logs:

TelegramError: ETELEGRAM: 400 Bad Request: user not found

An error occurs when using the getChatMember() method in the line:

let chatMember = await bot.getChatMember(users[i].chatId, users[i].userId)

chatId and userId are 100% correct. But the library or Telegram API suddenly stops seeing one of the users for some reason. Because of this, an error 400 takes off and the /stats command is not executed to the end. And the strangest thing is that the bug goes away for a while if the user (on whom getChatMember() breaks down) writes /stats.

Such a bug suddenly occurs at different times in different groups where the bot was added.

What I have read?

I have googled, but did not find a solution, because I haven't seen anyone with similar problems.

Versions

Version of node-telegram-bot-api - 0.54.0 Version of NodeJS - 16.13.1 Version of npm - 8.3.0 OS - Ubuntu 20.04.3 LTS

Expected Behavior

The getChatMember() method should not suddenly stop seeing one of the chat users.

Actual Behavior

The getChatMember() method suddenly stops seeing one of the chat users.

Steps to reproduce the Behavior

The most annoying thing is that the bug appears spontaneously and therefore cannot be easily repeated in a test environment. Therefore, I threw off the link to the public chat, where this bug manifested itself. Do not pay attention that the chat is in Russian. If necessary, I (@Alexal3) will answer you in English.

kamikazechaser commented 2 years ago

This is not an issue with the library. Maybe Telegram.

elbekyusupov commented 8 months ago

The same situation happened to me, even if I check by subscribing to the channel, it returns the status that it has left the channel, sometimes it works and sometimes it doesn't work, I tried sending a request to this endpoint in postman and it is the same