Как получить id пользователя telegram python

от admin

Как телеграмм боту получить id пользователя который нажал /start

Здравствуйте пишу бота на Python- pyTelegramBotApi. Нужно что бы при нажатии юзером на кнопку старт мне пришел его айди. как выполнить такой запрос ?

При нажатии юзером кнопки старт происходит отправка боту сообщения с командой ‘start’, а само сообщения содержит информацию, в том числе id юзера, достать который можно например таким хендлером:

user avatar

Обратите внимание на id и from_user .

Если нужно не id пользователя, а его имя, то используйте message.from_user.username

user avatar

user avatar

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

Site design / logo © 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2022.8.30.42948

Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.

telegram.User¶

Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their id is equal.

id ( int ) – Unique identifier for this user or bot.

is_bot ( bool ) – True , if this user is a bot.

first_name ( str ) – User’s or bots first name.

last_name ( str , optional) – User’s or bots last name.

username ( str , optional) – User’s or bots username.

language_code ( str , optional) – IETF language tag of the user’s language.

can_join_groups ( str , optional) – True , if the bot can be invited to groups. Returned only in telegram.Bot.get_me requests.

can_read_all_group_messages ( str , optional) – True , if privacy mode is disabled for the bot. Returned only in telegram.Bot.get_me requests.

supports_inline_queries ( str , optional) – True , if the bot supports inline queries. Returned only in telegram.Bot.get_me requests.

bot ( telegram.Bot , optional) – The Bot to use for instance methods.

is_premium ( bool , optional) –

True , if this user is a Telegram Premium user.

New in version 13.13.

added_to_attachment_menu ( bool , optional) –

True , if this user added the bot to the attachment menu.

New in version 13.13.

Unique identifier for this user or bot.

True , if this user is a bot.

User’s or bot’s first name.

Optional. User’s or bot’s last name.

Optional. User’s or bot’s username.

Optional. IETF language tag of the user’s language.

Optional. True , if the bot can be invited to groups. Returned only in telegram.Bot.get_me requests.

Optional. True , if privacy mode is disabled for the bot. Returned only in telegram.Bot.get_me requests.

Optional. True , if the bot supports inline queries. Returned only in telegram.Bot.get_me requests.

Optional. The Bot to use for instance methods.

Optional. True , if this user is a Telegram Premium user.

New in version 13.13.

Optional. True , if this user added the bot to the attachment menu.

New in version 13.13.

approve_join_request ( chat_id , timeout = None , api_kwargs = None ) ¶

For the documentation of the arguments, please see telegram.Bot.approve_chat_join_request() .

New in version 13.8.

On success, True is returned.

copy_message ( chat_id , message_id , caption = None , parse_mode = None , caption_entities = None , disable_notification = None , reply_to_message_id = None , allow_sending_without_reply = None , reply_markup = None , timeout = None , api_kwargs = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.copy_message() .

On success, instance representing the message posted.

decline_join_request ( chat_id , timeout = None , api_kwargs = None ) ¶

For the documentation of the arguments, please see telegram.Bot.decline_chat_join_request() .

New in version 13.8.

On success, True is returned.

Convenience property. The user’s first_name , followed by (if available) last_name .

get_menu_button ( timeout = None , api_kwargs = None ) ¶

For the documentation of the arguments, please see telegram.Bot.get_chat_menu_button() .

New in version 13.12.

On success, the current menu button is returned.

get_profile_photos ( offset = None , limit = 100 , timeout = None , api_kwargs = None ) ¶

For the documentation of the arguments, please see telegram.Bot.get_user_profile_photos() .

Convenience property. If username is available, returns a t.me link of the user.

mention_button ( name = None ) ¶

New in version 13.9.

name ( str ) – The name used as a link for the user. Defaults to full_name .

InlineButton with url set to the user mention

mention_html ( name = None ) ¶ Parameters

name ( str ) – The name used as a link for the user. Defaults to full_name .

The inline mention for the user as HTML.

mention_markdown ( name = None ) ¶

telegram.ParseMode.MARKDOWN is a legacy mode, retained by Telegram for backward compatibility. You should use mention_markdown_v2() instead.

name ( str ) – The name used as a link for the user. Defaults to full_name .

The inline mention for the user as markdown (version 1).

mention_markdown_v2 ( name = None ) ¶ Parameters

name ( str ) – The name used as a link for the user. Defaults to full_name .

The inline mention for the user as markdown (version 2).

Convenience property. If available, returns the user’s username prefixed with “@”. If username is not available, returns full_name .

pin_message ( message_id , disable_notification = None , timeout = None , api_kwargs = None ) ¶

For the documentation of the arguments, please see telegram.Bot.pin_chat_message() .

On success, True is returned.

send_action ( action , timeout = None , api_kwargs = None ) ¶

send_animation ( animation , duration = None , width = None , height = None , thumb = None , caption = None , parse_mode = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = 20 , api_kwargs = None , allow_sending_without_reply = None , caption_entities = None , filename = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_animation() .

On success, instance representing the message posted.

send_audio ( audio , duration = None , performer = None , title = None , caption = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = 20 , parse_mode = None , thumb = None , api_kwargs = None , allow_sending_without_reply = None , caption_entities = None , filename = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_audio() .

On success, instance representing the message posted.

send_chat_action ( action , timeout = None , api_kwargs = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_chat_action() .

send_contact ( phone_number = None , first_name = None , last_name = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = None , contact = None , vcard = None , api_kwargs = None , allow_sending_without_reply = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_contact() .

On success, instance representing the message posted.

send_copy ( from_chat_id , message_id , caption = None , parse_mode = None , caption_entities = None , disable_notification = None , reply_to_message_id = None , allow_sending_without_reply = None , reply_markup = None , timeout = None , api_kwargs = None , protect_content = None ) ¶

Читать:
Telegram desktop как добавить много аккаунтов

For the documentation of the arguments, please see telegram.Bot.copy_message() .

On success, instance representing the message posted.

send_dice ( disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = None , emoji = None , api_kwargs = None , allow_sending_without_reply = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_dice() .

On success, instance representing the message posted.

send_document ( document , filename = None , caption = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = 20 , parse_mode = None , thumb = None , api_kwargs = None , disable_content_type_detection = None , allow_sending_without_reply = None , caption_entities = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_document() .

On success, instance representing the message posted.

send_game ( game_short_name , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = None , api_kwargs = None , allow_sending_without_reply = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_game() .

On success, instance representing the message posted.

send_invoice ( title , description , payload , provider_token , currency , prices , start_parameter = None , photo_url = None , photo_size = None , photo_width = None , photo_height = None , need_name = None , need_phone_number = None , need_email = None , need_shipping_address = None , is_flexible = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , provider_data = None , send_phone_number_to_provider = None , send_email_to_provider = None , timeout = None , api_kwargs = None , allow_sending_without_reply = None , max_tip_amount = None , suggested_tip_amounts = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_invoice() .

As of API 5.2 start_parameter is an optional argument and therefore the order of the arguments had to be changed. Use keyword arguments to make sure that the arguments are passed correctly.

Changed in version 13.5: As of Bot API 5.2, the parameter start_parameter is optional.

On success, instance representing the message posted.

send_location ( latitude = None , longitude = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = None , location = None , live_period = None , api_kwargs = None , horizontal_accuracy = None , heading = None , proximity_alert_radius = None , allow_sending_without_reply = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_location() .

On success, instance representing the message posted.

send_media_group ( media , disable_notification = None , reply_to_message_id = None , timeout = 20 , api_kwargs = None , allow_sending_without_reply = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_media_group() .

] On success, instance representing the message posted.

send_message ( text , parse_mode = None , disable_web_page_preview = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = None , api_kwargs = None , allow_sending_without_reply = None , entities = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_message() .

On success, instance representing the message posted.

send_photo ( photo , caption = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = 20 , parse_mode = None , api_kwargs = None , allow_sending_without_reply = None , caption_entities = None , filename = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_photo() .

On success, instance representing the message posted.

send_poll ( question , options , is_anonymous = True , type = ‘regular’ , allows_multiple_answers = False , correct_option_id = None , is_closed = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = None , explanation = None , explanation_parse_mode = None , open_period = None , close_date = None , api_kwargs = None , allow_sending_without_reply = None , explanation_entities = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_poll() .

On success, instance representing the message posted.

send_sticker ( sticker , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = 20 , api_kwargs = None , allow_sending_without_reply = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_sticker() .

On success, instance representing the message posted.

send_venue ( latitude = None , longitude = None , title = None , address = None , foursquare_id = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = None , venue = None , foursquare_type = None , api_kwargs = None , google_place_id = None , google_place_type = None , allow_sending_without_reply = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_venue() .

On success, instance representing the message posted.

send_video ( video , duration = None , caption = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = 20 , width = None , height = None , parse_mode = None , supports_streaming = None , thumb = None , api_kwargs = None , allow_sending_without_reply = None , caption_entities = None , filename = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_video() .

On success, instance representing the message posted.

send_video_note ( video_note , duration = None , length = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = 20 , thumb = None , api_kwargs = None , allow_sending_without_reply = None , filename = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_video_note() .

On success, instance representing the message posted.

send_voice ( voice , duration = None , caption = None , disable_notification = None , reply_to_message_id = None , reply_markup = None , timeout = 20 , parse_mode = None , api_kwargs = None , allow_sending_without_reply = None , caption_entities = None , filename = None , protect_content = None ) ¶

For the documentation of the arguments, please see telegram.Bot.send_voice() .

On success, instance representing the message posted.

set_menu_button ( menu_button = None , timeout = None , api_kwargs = None ) ¶

For the documentation of the arguments, please see telegram.Bot.set_chat_menu_button() .

New in version 13.12.

On success, True is returned.

unpin_all_messages ( timeout = None , api_kwargs = None ) ¶

For the documentation of the arguments, please see telegram.Bot.unpin_all_chat_messages() .

On success, True is returned.

unpin_message ( timeout = None , api_kwargs = None , message_id = None ) ¶

Получение ID человека в по юзернейму

Получение id человека из БД который нажал на кнопку
Здравствуйте. Я отправляю человеку с помощью php mail() сообщение на почту, у него есть две кнопки.

Известны год и номер месяца рождения человека, определить возраст человека
Известны год и номер месяца рождения человека, а также год и номер месяца сегодняшнего дня (январь.

адресс человека по номеру телефона найти человека в питере?
скажите как мне найти адрес человека по номеру телефона в питере?

Дано число n, определяющее возраст человека (в месяцах). Выразить возраст человека годах и в месяцах
Здравствуйте,помогите пожалуйста. Дано число n(1≤n≤1188), определяющее возраст человека (в.

Реализуйте класс для хранения ФИО и номера телефона человека, класс для хранения даты рождения человека, а также класс для хранения ФИО и почтового ад
Реализуйте класс для хранения ФИО и номера телефона человека, класс для хранения даты рождения.

Имитировать человека
Добрый день ув. пользователи! Подскажите пожалуйста можно ли как-то имитировать человека, допустим.

Нарисовать человека
Изобразить на экране ЭВМ следующий рисунок:

Возраст человека
Как вычислить возраст человека и поставить "+" в нужную ячейку от "17" до "23+"?

Возраст человека
Ввести возраст человека (от 1 до 150) и вывести его с последующими словом "год", "года" или "лет".

Похожие статьи