eternnoir / pyTelegramBotAPI

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

chat member handlers are not work for big groups #2333

Closed ABIRHOSSAIN10 closed 1 week ago

ABIRHOSSAIN10 commented 3 weeks ago

import telebot from telebot.types import ChatMemberUpdated import logging import config

Configure logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

bot = telebot.TeleBot('')

@bot.chat_member_handler() def handle_chat_member_update(chat_member_update: ChatMemberUpdated): print(chat_member_update) print(ChatMemberUpdated) try: if chat_member_update.new_chat_member.status == 'member': bot.send_message(chat_member_update.chat.id, f"Welcome, {chat_member_update.new_chat_member.user.first_name}!") elif chat_member_update.new_chat_member.status in ['left', 'kicked']: bot.send_message(chat_member_update.chat.id, f"Goodbye, {chat_member_update.new_chat_member.user.first_name}!") except Exception as e: logging.error(f"Error handling chat member update: {e}")

bot.polling()

Found another problem it dosent trigger the handler. My bot is an admin. But still not doing anything seconde i tryed This @bot.message_handler(content_types=['new_chat_members'])

Its only work for Small group

Badiboy commented 3 weeks ago

image

Did you?

Badiboy commented 3 weeks ago
try:
**************
if chat_member_update.new_chat_member.status == 'member':

Additionally add some output here. Just to be sure it really DOES NOT trigger.

ABIRHOSSAIN10 commented 3 weeks ago
try:
**************
if chat_member_update.new_chat_member.status == 'member':

Additionally add some output here. Just to be sure it really DOES NOT trigger.

I tryed many times but That function never triggered

Badiboy commented 3 weeks ago

I tryed many times but That function never triggered

This function works fine, so the only thing you should do - inspect your code deeper to find the reason. So please check once again:

  1. If you obviously mentioned "chat_member" in "allowed_updates".
  2. The function is triggerd by printing info without any conditions.
ABIRHOSSAIN10 commented 2 weeks ago

I tryed many times but That function never triggered

This function works fine, so the only thing you should do - inspect your code deeper to find the reason. So please check once again:

  1. If you obviously mentioned "chat_member" in "allowed_updates".
  2. The function is triggerd by printing info without any conditions.

Mybe you should try it now then you can say that its work.make sure at least group Member is 1k.

coder2020official commented 1 week ago

reopen if needed.