from telebot.types import ReplyKeyboardMarkup, KeyboardButton
import random
# Создание бота и клавиатуры
bot = telebot.TeleBot('6621979927:AAFDCvy1yqnZBEEfpDjOY2JVp5PeVdVrpAc')
keyboard = ReplyKeyboardMarkup()
keyboard.add(KeyboardButton('New Jazz'), KeyboardButton('Drill'), KeyboardButton('Trap'), KeyboardButton('Jercey Club'),
KeyboardButton('Detroit'))
# Словарь композиций для каждого жанра
compositions = {
'New Jazz': ['Composition 1', 'Composition 2', 'Composition 3'],
'Drill': ['Composition 4', 'Composition 5', 'Composition 6'],
'Trap': ['Composition 7', 'Composition 8', 'Composition 9'],
'Jercey Club': ['Composition 10', 'Composition 11', 'Composition 12'],
'Detroit': ['Composition 13', 'Composition 14', 'Composition 15']
}
# Словарь для хранения текущего выбранного жанра
user_genres = {}
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.chat.id, "Привет! Здесь ты можешь выбрать жанр нужного бита:", reply_markup=keyboard)
@bot.message_handler(func=lambda message: message.text in ['New Jazz', 'Drill', 'Trap', 'Jercey Club', 'Detroit'])
def select_composition(message):
genre = message.text
genre_compositions = compositions[genre]
random_composition = random.choice(genre_compositions)
# Сохраняем выбранный жанр пользователя
user_genres[message.chat.id] = genre
bot.send_message(message.chat.id, f"Композиция: {random_composition}")
next_keyboard = ReplyKeyboardMarkup()
next_keyboard.add(KeyboardButton('Далее'), KeyboardButton('В главное меню'))
bot.send_message(message.chat.id, "Что вы хотите сделать?", reply_markup=next_keyboard)
@bot.message_handler(func=lambda message: message.text == 'Далее')
def next_composition(message):
user_id = message.chat.id
# Проверяем, был ли уже выбран жанр пользователем
if user_id in user_genres:
genre = user_genres[user_id]
genre_compositions = compositions[genre]
random_composition = random.choice(genre_compositions)
bot.send_message(user_id, f"Композиция: {random_composition}")
next_keyboard = ReplyKeyboardMarkup()
next_keyboard.add(KeyboardButton('Далее'), KeyboardButton('В главное меню'))
bot.send_message(user_id, "Что вы хотите сделать?", reply_markup=next_keyboard)
else:
bot.send_message(user_id, "Сначала выберите жанр.")
@bot.message_handler(func=lambda message: message.text == 'В главное меню')
def main_menu(message):
user_id = message.chat.id
user_genres.pop(user_id, None)
start(message)
bot.polling(none_stop=True)```