import telebot
import time
from telebot import types
bot_token = "TOKEN"
bot = telebot.TeleBot(token=bot_token)
@bot.message_handler (commands= ['start'])
def start (message):
global chat_id, x, y, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, yakList
yakList = ["sanam", "besh"]
x = message.from_user.first_name
y = message.from_user.last_name
chat_id = message.chat.id
markup_inline = types.InlineKeyboardMarkup ()
item_eng = types.InlineKeyboardButton (text = 'English', callback_data = 'eng')
item_ru = types.InlineKeyboardButton (text = 'Русский', callback_data = 'ru')
item_uzb = types.InlineKeyboardButton (text = "O'zbekcha", callback_data = 'uzb')
markup_inline.add (item_eng, item_ru, item_uzb)
bot.send_message (message.chat.id, 'Choose language/Выберите язык/Tilni tanlang', reply_markup = markup_inline)
@bot.callback_query_handler(func = lambda call: True)
def callback_inline(call):
global first
first = ["Well done! Now I have to define your name.", "ikki"]
if call.data == 'eng':
first = str(first[0])
main(call)
elif call.data == 'ru':
first = str(first[1])
main(call)
def main(call):
bot.edit_message_text ("{}".format(first), call.message.chat.id, call.message.message_id)
time.sleep(1)
markup_ask = types.InlineKeyboardMarkup()
item_yes = types.InlineKeyboardButton(text = 'Yes', callback_data = 'yes')
item_change = types.InlineKeyboardButton(text = "I'd like to change", callback_data = 'change')
markup_ask.add(item_yes, item_change)
bot.send_message(chat_id, "Leave it as " + x + " " + y + "?", reply_markup = markup_ask)
# Вот здесь перестаёт отвечать..........
@bot.callback_query_handler(func = lambda call: True)
def callback_inline(call):
if call.data == 'yes':
bot.edit_message_text('Отлично', call.message.chat.id, call.message.message_id)
body()
else:
bot.edit_message_text('Плохо', call.message.chat.id, call.message.message_id)
body()
def body():
bot.send_message(chat_id, "ggwp")
bot.polling()