Код :
Python:
import telebot
from telebot import types
bot = telebot.TeleBot('1621015644:AAGC9alLMjv3MCT4G66tNoYE4wvgb6RKCSo')
@bot.message_handler(commands = ['start'])
def get_user_info(message):
markup_inline = types.InlineKeyboardMarkup()
item_yes = types.InlineKeyboardButton(text = 'ДА', callback_data='yes')
item_no = types.InlineKeyboardButton(text = 'НЕТ', callback_data='no')
markup_inline.add(item_yes, item_no)
bot.send_message(message.chat.id, text='Хотите узнать информацию о вас?',
reply_markup=markup_inline)
@bot.callback_query_handler(func = lambda call: True)
def answer(call):
if call.data == 'yes':
markup_reply = types.ReplyKeyboardMarkup(resize_keyboard=True)
user_id = types.KeyboardButton(text='МОЙ ID')
user_name = types.KeyboardButton(text='МОЙ НИК')
markup_reply.add(user_id, user_name)
bot.send_message(call.message.chat.id, text='Что вы хотите узнать?)',
reply_markup=markup_reply)
elif call.data == 'no':
pass
@bot.message_handler(content_types = ['text'])
def get_text(message):
if message.text == 'МОЙ ID':
bot.send_message(message.chat.id, text=f'Твой ID: {message.from_user.id}')
elif message.text == 'МОЙ НИК':
bot.send_message(message.chat.id, text=f'Твоё имя: {message.from_user.first_name} {message.from_user.last_name}')
bot.polling()