from telebot import types
import telebot
bot = telebot.TeleBot("Токен")
vkhelper = telebot.types.ReplyKeyboardMarkup(True)
vkhelper.row("Регистрация")
pname = ""
print("Bot started")
@bot.message_handler(commands=["start"])
def start_message(message):
bot.send_message(message.chat.id, "Привет, зарегистрируйся", reply_markup = vkhelper)
@bot.message_handler(content_types = ["text"])
def get_text_messages(message):
if message.text.lower() == "регистрация":
bot.send_message(message.from_user.id, "Введите ваше имя: ", reply_markup = vkhelper)
bot.register_next_step_handler(message, get_name)
def get_name(message):
global pname
pname = message.text
keyboard = types.InlineKeyboardMarkup()
keyboard.row(
telebot.types.InlineKeyboardButton("Да", callback_data = "yes"),
telebot.types.InlineKeyboardButton("Нет", callback_data = "no"))
question = "Ваше имя: {0}".format(pname)
bot.send_message(message.from_user.id, text = question, reply_markup = keyboard)
@bot.callback_query_handler(func = lambda call: True)
def callback_worker(call):
if call.data == "yes":
bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text = "Отлично", parse_mode = "Markdown")
elif call.data == "no":
pass
# Тут нужно чтобы пользователь сразу ввёл своё имя
bot.polling(none_stop = True, interval = 0)