Пример #1
0
async def handle_select_book(call: CallbackQuery):
    """Select audiobook button handler."""
    callback(call)
    authors_and_genres_menu = create_authors_and_genres_menu()
    # keyboard authors and genres
    await call.message.answer(
        text='Выберите аудиокнигу по автору, жанру или исполнителю. \n'
        'Если передумали - вернитесь в меню',
        reply_markup=authors_and_genres_menu)
Пример #2
0
async def handle_author_id_and_book_page(call: CallbackQuery):
    """Author's id and book's page number handler."""
    author_id_and_book_page = callback(call).replace('author_id_book_page_', '') \
                                            .split('/')
    author_id = author_id_and_book_page[0]
    current_page = author_id_and_book_page[1]
    await send_author_books_by_item_id(call, int(author_id), int(current_page),
                                       Books.author_id)
Пример #3
0
async def handle_genre_id_and_book_page(call: CallbackQuery):
    """Genre's id and book's page number handler."""
    genre_id_and_book_page = callback(call).replace('genre_id_book_page_', '') \
                                           .split('/')
    genre_id = genre_id_and_book_page[0]
    current_page = genre_id_and_book_page[1]
    await send_genre_books_by_item_id(call, int(genre_id), int(current_page),
                                      Genres.id)
Пример #4
0
async def handle_reader_id_and_book_page(call: CallbackQuery):
    """Reader's id and book's page number handler."""
    reader_id_and_book_page = callback(call).replace('reader_id_book_page_', '') \
                                            .split('/')
    reader_id = reader_id_and_book_page[0]
    current_page = reader_id_and_book_page[1]
    await send_reader_books_by_item_id(call, int(reader_id), int(current_page),
                                       Readers.id)
Пример #5
0
async def handle_author_page(call: CallbackQuery):
    """Author's page handler."""
    current_page = callback(call).replace('author_page_', '')
    # keyboard authors
    await send_authors_with_pages(call, int(current_page))
Пример #6
0
async def handle_genre_page(call: CallbackQuery):
    """Genre's page handler."""
    current_page = callback(call).replace('genre_page_', '')
    # keyboard genres
    await send_genres_with_pages(call, int(current_page))
Пример #7
0
async def handle_random_book(call: CallbackQuery):
    """Select a 'Random audiobook' button handler."""
    callback(call)
    count_books = get_count_books()
    random_book_id = random.randint(1, count_books)
    await send_book_by_book_id(call, random_book_id)
Пример #8
0
async def handle_reader_page(call: CallbackQuery):
    """Genre's page handler."""
    current_page = callback(call).replace('reader_page_', '')
    # keyboard reader
    await send_readers_with_pages(call, int(current_page))
Пример #9
0
async def handle_book_id_and_book_url(call: CallbackQuery):
    """Book's id and book's url handler."""
    book_id = callback(call).replace('book_id_', '')
    await send_book_by_book_id(call, book_id)