pengrad / java-telegram-bot-api

Telegram Bot API for Java

Home Page:https://core.telegram.org/bots

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting ID through arguments

scar-day opened this issue · comments

Hello, is there any function that gives user ID through arguments (for example I write like this: /id @ and it will give ID)

Hello, if you mean that you need to get the ID of users without using BOTs API then you can use unofficial apps (like Plus Messenger on Android or Nicegram on iOS). You will be able to see the User ID in the User profile.
If you are looking instead to create a Telegram BOT that will send you the of users that starts it, you can do something like this:

if (update.message() != null && update.message().text() != null && update.message.text().equals("/start")) {
SendMessage msg = new SendMessage(YOUR_TELEGRAM_ID, "User started the bot: " + update.message().from().id());
bot.execute(msg);
}