1

Необходимо достать из бота его @username (@name_bot) по API. В документации ничего не нашел по этому поводу.

1 ответ 1

4

getMe

Простой метод проверки токена аутентификации вашего бота. Не требует параметров. Возвращает основную информацию о боте в виде объекта User.

Поле username - Имя пользователя или бота

import telebot


bot = telebot.TeleBot(bot_token)

print(bot.get_me())
print(bot.get_me().username)

bot.polling(none_stop=True)

>>> {'id': 99**66, 'is_bot': True, 'first_name': 'example', 'username': 'example_bot', 'last_name': None, 'language_code': None, 'can_join_groups': True, 'can_read_all_group_messages': False, 'supports_inline_queries': False}

>>> example_bot

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.