eternnoir / pyTelegramBotAPI

Python Telegram bot api.
GNU General Public License v2.0
8.02k stars 2.02k forks source link

new_chat_members isn't updating on big groups (100k users) #1250

Closed Bal-Gu closed 3 years ago

Bal-Gu commented 3 years ago

pyTelegramBotAPI version: 3.8.2 OS: Windows 10 Python: 3.7

To get new updates when a user is joining I use the following function:

@bot.message_handler(content_types=["new_chat_members"])
def blackList(message):
# some code to block certain names

The snippet works fine on smaller groups (20k users). What I have noticed is that on higher groups they are turning off the "user x has joined" notification/label. I supposed that this function relied on that message in the chat which would also be visible in the JSON when pooling the data from the server.

So in the meanwhile is there any other option that would show us the latest user that joined? I tried with bot.chat(IDOfChat) but the new_chat_members is equal to NONE.

Any help would be preciated.

coder2020official commented 3 years ago

Hi!

Recently, there was a warning in telegram bot api website. Read below: Service messages about non-bot users joining the chat will be soon removed from large groups. We recommend using the “chat_member” update as a replacement. So, you should use chatMember from now. Here are some useful things: Using new handlers More on new handlers: We have my chat member handler, it is used when bot is added to group. chat member handler is for any people entering the chat When the status of a user changes, telegram gives update that his status has changed. Read more on statuses

Bal-Gu commented 3 years ago

Thank you I will try it out and report if it helped.

Bal-Gu commented 3 years ago

@coder2020official thank you that worked. For future references make sure to use:

bot.polling(allowed_updates=util.update_types)

Without it it won't work.

MaGua-Bishop commented 2 days ago

Thanks, this problem has been bothering me for three days, but my code is webhook, and I found that I only need to add

allowed_updates=util.update_types parameter to set_webhook to receive member addition information