mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-05-08 17:40:02 +00:00
UserChatShared
A bot that demonstrates the RequestUsers and RequestChat keyboard button types, letting users
share user or chat contacts with the bot.
Functionality
On /start, the bot sends a reply keyboard containing various request buttons. When the user taps
one of these buttons, Telegram opens a picker and the selected user(s) or chat is shared back with
the bot. The bot then logs and replies with the received share information.
Arguments
| Position | Value | Sample | Description |
|---|---|---|---|
| 1 | BOT_TOKEN |
1234567890:AABBccDDeeFF |
Telegram bot token |
Optional arguments (any order after the token):
| Value | Sample | Description |
|---|---|---|
debug |
debug |
Enable verbose debug logging |
testServer |
testServer |
Connect to the Telegram test server instead of production |
Bot Commands
| Command | Description |
|---|---|
/start |
Sends the reply keyboard with all request buttons |
Capabilities
RequestUsersbuttons for: any single user, premium user, non-premium user, multiple usersRequestChatbuttons for: any channel, any group, a forum group, a group with specific privacy/creator requirements- Buttons can optionally request the user's/chat's photo, name, and username
- Unique request IDs are assigned to each button to distinguish responses
- Handles
UserSharedandChatSharedservice messages and replies with the received data - Runs via long polling
Launch
../gradlew run --args="BOT_TOKEN"