yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.3k stars 1.5k forks source link

'new_chat_members' is group over 10k member not working #1001

Closed kjh9852 closed 2 years ago

kjh9852 commented 2 years ago

hello

my test group is under 10k members, when a new member join my group, everything work fine

But when my group reach 10k members. bot can not get the 'new_chat_members' event not working I don't see new_chat_members in api either

my code

bot.on('message', function(message) {
    if (message.new_chat_members != undefined) {
        bot.sendMessage(message.chat.id, message.new_chat_member.username + " joined!");
    }
});
danielperez9430 commented 2 years ago

Hi @kjh9852 this method is actually more for the groups with less that 10K, if your chat have more that 10K you need to listen "chat_member" event. You can the in this link the code for enable this update: https://github.com/yagop/node-telegram-bot-api/issues/923#issuecomment-996038501

kjh9852 commented 2 years ago

@danielperez9430 Thank you for your answer. I attempt #923. I don't know where to put this code. image

My fullcode


const TelegramBot = require('node-telegram-bot-api');
const TOKEN = 'xxx';
const bot = new TelegramBot(TOKEN, {
    polling: {
        params: {
            "allowed_updates": JSON.stringify(["update_id", "message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_member"])
        }
    }
});

bot.on('message', function(message) {
    if (message.new_chat_members != undefined) {
        bot.sendMessage(message.chat.id, message.new_chat_member.username + " joined!");
    }
});
``
danielperez9430 commented 2 years ago

The code that you have is correct, but you need to listen bot.on("chat_member", (msg) => {})

bluetyphoon77 commented 7 months ago

@danielperez9430 @kjh9852 Hi guyz, Seems there is a problem with this event in the library now. Is this new_chat_members still working for you and detecting new users joining your group as it should? Thanks in advance. Cheers