заготовка бота
This commit is contained in:
parent
e397f67f56
commit
5f9eb980c1
42
dodo-bot.py
42
dodo-bot.py
@ -6,3 +6,45 @@ from telebot import types
|
|||||||
|
|
||||||
key_api = input("Укажите ключ бота")
|
key_api = input("Укажите ключ бота")
|
||||||
dodo_bot = telebot.Telebot(f"{key_api}", parse_mode=None)
|
dodo_bot = telebot.Telebot(f"{key_api}", parse_mode=None)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commans=['start', 'help'])
|
||||||
|
def start_bot(message):
|
||||||
|
bot.reply_to(message, message.text)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(content_types=['text'])
|
||||||
|
def menu(a):
|
||||||
|
if a.text == "Inline_menu":
|
||||||
|
mainmenu = types.InlineKeyboardMarkup()
|
||||||
|
key1 = types.InlineKeyboardButton(text='Кнопка 1', callback_data='key1')
|
||||||
|
key2 = types.InlineKeyboardButton(text='Кнопка 2', callback_data='key2')
|
||||||
|
mainmenu.add(key1, key2)
|
||||||
|
bot.send_message(a.chat.id, 'Это главное меню!', reply_markup=mainmenu)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.callback_query_handler(func=lambda call: True)
|
||||||
|
def back(call):
|
||||||
|
if call.data == "mainmenu":
|
||||||
|
mainmenu = types.InlineKeyboardMarkup()
|
||||||
|
key1 = types.InlineKeyboardButton(text='Кнопка 1', callback_data='key1')
|
||||||
|
key2 = types.InlineKeyboardButton(text='Кнопка 2', callback_data='key2')
|
||||||
|
mainmenu.add(key1, key2)
|
||||||
|
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id, reply_markup=mainmenu)
|
||||||
|
elif call.data == "key1":
|
||||||
|
next_menu = types.InlineKeyboardMarkup()
|
||||||
|
key3 = types.InlineKeyboardButton(text='Кнопка 3', callback_data='key3')
|
||||||
|
back = types.InlineKeyboardButton(text='Назад', callback_data='mainmenu')
|
||||||
|
next_menu.add(key3, back)
|
||||||
|
bot.edit_message_text('Это меню уровня 2, для кнопки1!', call.message.chat.id, call.message.message_id,
|
||||||
|
reply_markup=next_menu)
|
||||||
|
elif call.data == "key2":
|
||||||
|
next_menu2 = types.InlineKeyboardMarkup()
|
||||||
|
key4 = types.InlineKeyboardButton(text='Кнопка 4', callback_data='key4')
|
||||||
|
back = types.InlineKeyboardButton(text='Назад', callback_data='mainmenu')
|
||||||
|
next_menu2.add(key4, back)
|
||||||
|
bot.edit_message_text('Это меню уровня 2, для кнопки2!', call.message.chat.id, call.message.message_id,
|
||||||
|
reply_markup=next_menu2)
|
||||||
|
|
||||||
|
|
||||||
|
bot.polling()
|
Loading…
Reference in New Issue
Block a user