заготовка
This commit is contained in:
parent
7c16a2cb34
commit
17b0cc8a17
20
dodo-bot.py
20
dodo-bot.py
@ -5,46 +5,46 @@ import telebot
|
|||||||
from telebot import types
|
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'])
|
@dodo_bot.message_handler(commans=['start', 'help'])
|
||||||
def start_bot(message):
|
def start_bot(message):
|
||||||
bot.reply_to(message, message.text)
|
dodo_bot.reply_to(message, message.text)
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(content_types=['text'])
|
@dodo_bot.message_handler(content_types=['text'])
|
||||||
def menu(a):
|
def menu(a):
|
||||||
if a.text == "Inline_menu":
|
if a.text == "Inline_menu":
|
||||||
mainmenu = types.InlineKeyboardMarkup()
|
mainmenu = types.InlineKeyboardMarkup()
|
||||||
key1 = types.InlineKeyboardButton(text='Кнопка 1', callback_data='key1')
|
key1 = types.InlineKeyboardButton(text='Кнопка 1', callback_data='key1')
|
||||||
key2 = types.InlineKeyboardButton(text='Кнопка 2', callback_data='key2')
|
key2 = types.InlineKeyboardButton(text='Кнопка 2', callback_data='key2')
|
||||||
mainmenu.add(key1, key2)
|
mainmenu.add(key1, key2)
|
||||||
bot.send_message(a.chat.id, 'Это главное меню!', reply_markup=mainmenu)
|
dodo_bot.send_message(a.chat.id, 'Это главное меню!', reply_markup=mainmenu)
|
||||||
|
|
||||||
|
|
||||||
@bot.callback_query_handler(func=lambda call: True)
|
@dodo_bot.callback_query_handler(func=lambda call: True)
|
||||||
def back(call):
|
def back(call):
|
||||||
if call.data == "mainmenu":
|
if call.data == "mainmenu":
|
||||||
mainmenu = types.InlineKeyboardMarkup()
|
mainmenu = types.InlineKeyboardMarkup()
|
||||||
key1 = types.InlineKeyboardButton(text='Кнопка 1', callback_data='key1')
|
key1 = types.InlineKeyboardButton(text='Кнопка 1', callback_data='key1')
|
||||||
key2 = types.InlineKeyboardButton(text='Кнопка 2', callback_data='key2')
|
key2 = types.InlineKeyboardButton(text='Кнопка 2', callback_data='key2')
|
||||||
mainmenu.add(key1, key2)
|
mainmenu.add(key1, key2)
|
||||||
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id, reply_markup=mainmenu)
|
dodo_bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id, reply_markup=mainmenu)
|
||||||
elif call.data == "key1":
|
elif call.data == "key1":
|
||||||
next_menu = types.InlineKeyboardMarkup()
|
next_menu = types.InlineKeyboardMarkup()
|
||||||
key3 = types.InlineKeyboardButton(text='Кнопка 3', callback_data='key3')
|
key3 = types.InlineKeyboardButton(text='Кнопка 3', callback_data='key3')
|
||||||
back = types.InlineKeyboardButton(text='Назад', callback_data='mainmenu')
|
back = types.InlineKeyboardButton(text='Назад', callback_data='mainmenu')
|
||||||
next_menu.add(key3, back)
|
next_menu.add(key3, back)
|
||||||
bot.edit_message_text('Это меню уровня 2, для кнопки1!', call.message.chat.id, call.message.message_id,
|
dodo_bot.edit_message_text('Это меню уровня 2, для кнопки1!', call.message.chat.id, call.message.message_id,
|
||||||
reply_markup=next_menu)
|
reply_markup=next_menu)
|
||||||
elif call.data == "key2":
|
elif call.data == "key2":
|
||||||
next_menu2 = types.InlineKeyboardMarkup()
|
next_menu2 = types.InlineKeyboardMarkup()
|
||||||
key4 = types.InlineKeyboardButton(text='Кнопка 4', callback_data='key4')
|
key4 = types.InlineKeyboardButton(text='Кнопка 4', callback_data='key4')
|
||||||
back = types.InlineKeyboardButton(text='Назад', callback_data='mainmenu')
|
back = types.InlineKeyboardButton(text='Назад', callback_data='mainmenu')
|
||||||
next_menu2.add(key4, back)
|
next_menu2.add(key4, back)
|
||||||
bot.edit_message_text('Это меню уровня 2, для кнопки2!', call.message.chat.id, call.message.message_id,
|
dodo_bot.edit_message_text('Это меню уровня 2, для кнопки2!', call.message.chat.id, call.message.message_id,
|
||||||
reply_markup=next_menu2)
|
reply_markup=next_menu2)
|
||||||
|
|
||||||
|
|
||||||
bot.polling()
|
dodo_bot.polling()
|
Loading…
Reference in New Issue
Block a user