rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.68k stars 1.18k forks source link

Hello, how can I let the robot automatically know that a new user has joined the group? #1206

Open 1104190950 opened 1 year ago

1104190950 commented 1 year ago

Hello, how can I let the robot automatically know that a new user has joined the group? I want to implement the function that the BOT sends a verification code for the user to verify after the new user joins the group

saqoah commented 1 year ago

use private static final String NEWCHATMEMBERS_FIELD = "new_chat_members";

if ( update.message.newChatMembers.isNotEmpty() ) {
                val newChatMembers = update.message.newChatMembers
                //
}

you get a (Mutable)List<User!>! as a result

samosxin commented 1 year ago

if group is public, Maybe I don't get the update information