import telebot
from telebot import types
TOKEN = '<TOKEN>'
bot = telebot.TeleBot(TOKEN)
# Обычный режим
@bot.message_handler(content_types=["text"])
def any_msg(message):
keyboard = types.InlineKeyboardMarkup()
callback_button1 = types.InlineKeyboardButton(text="turn off", callback_data="off")
keyboard.add(callback_button1)
bot.send_message(message.chat.id, "Свет включен", reply_markup=keyboard)
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.message:
if call.data == "off":
keyboard = types.InlineKeyboardMarkup()
callback_button2 = types.InlineKeyboardButton(text="turn on", callback_data="on")
keyboard.add(callback_button2)
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Свет выключен", reply_markup=keyboard)
elif call.data == "on":
keyboard = types.InlineKeyboardMarkup()
callback_button1 = types.InlineKeyboardButton(text="turn off", callback_data="off")
keyboard.add(callback_button1)
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Свет вкючен", reply_markup=keyboard)
if __name__ == '__main__':
bot.polling(none_stop=True)
пробую вот так, но пока не получается