Reputation: 3648
I know how to get the username of a user that send an update or message to my bot but how can I get the username and/or name of my bot without resorting to BotFather?
Upvotes: 0
Views: 1523
Reputation: 43884
How can I get the username and/or name of my bot
The Telegram Bot API provides a getMe
method that:
A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
So, if you'd send a request like:
api.telegram.org/bot<MY-BOT-TOKEN>/getMe
You'll get the following response:
{
"ok": true,
"result": {
"id": 12346798,
"is_bot": true,
"first_name": "my_test_bot",
"username": "my_test_bot",
"can_join_groups": true,
"can_read_all_group_messages": false,
"supports_inline_queries": false
}
}
Upvotes: 2