rubenlagus / TelegramBots

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

how get user name and name in bot #258

Closed mbarzegar93 closed 7 years ago

mbarzegar93 commented 7 years ago

hi i want to get my users user names and their name right now i cat save their chat id [update.getMessage().getChatId()] how can i get their user name and their name too?? please with example tnx

rubenlagus commented 7 years ago

Inside Message object returned by getMessage() you will find a the from field with the user information.

mbarzegar93 commented 7 years ago

i don't have from field in getMessage() i use telegrambots 2.4.4.5 library? is the library version is a problem???or it not implemented yet?

rubenlagus commented 7 years ago

As you can see, it is present, everything defined in the official docs API is present: https://github.com/rubenlagus/TelegramBots/blob/2.4.4.5/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Message.java#L55

mbarzegar93 commented 7 years ago

problem solved tnx i should use update.getMessage().getFrom().getUserName() for getting user name