from loader import dp, photo_db @dp.callback_query_handler(place_callback.filter(item_name="vor_r")) async def vor_region_pag(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) text = get_page(Voroshil_text) photo = get_page(Voroshil_photo) await call.message.answer_photo( photo=open(photo_db.get_one_file_name(name=photo), 'rb'), reply_markup=get_page_keyboard(k="vor", max=max_vor)) await call.message.answer(text=text, reply_markup=get_text(max=max_vor, k="vor_t")) @dp.callback_query_handler(pagination_call.filter(key="vor")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page = int(callback_data.get("page")) photo = get_page(array=Voroshil_photo, page=current_page) media = InputMediaPhoto(media=open(photo_db.get_one_file_name( name=photo), 'rb')) markup = get_page_keyboard(k="vor", max=max_vor, page=current_page) await call.message.edit_media(media=media, reply_markup=markup) @dp.callback_query_handler(pagination_call.filter(key="vor_t")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page = int(callback_data.get("page")) text = get_page(array=Voroshil_text, page=current_page)
from keyboards.inline.callback_datas import place_callback, pagination_call from keyboards.inline.encyclopedia import get_page_keyboard, get_text from loader import dp, photo_db @dp.callback_query_handler(place_callback.filter(item_name="len_r")) async def len_region_pag(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) text= get_page(Leninsky_text) photo=get_page(Leninsky_photo) await call.message.answer_photo(photo=open(photo_db.get_one_file_name(name=photo), 'rb'), reply_markup=get_page_keyboard(k="len",max=max_len)) await call.message.answer(text=text, reply_markup=get_text(max=max_len,k="len_t")) @dp.callback_query_handler(pagination_call.filter(key="len")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page=int(callback_data.get("page")) photo = get_page(array=Leninsky_photo,page=current_page) media=InputMediaPhoto(media=open(photo_db.get_one_file_name(name=photo),'rb')) markup=get_page_keyboard(k="len",max=max_len,page=current_page) await call.message.edit_media(media= media, reply_markup=markup) @dp.callback_query_handler(pagination_call.filter(key="len_t")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page=int(callback_data.get("page")) text=get_page(array=Leninsky_text,page=current_page) await call.message.edit_text(text=text, reply_markup=get_text(k="len_t",max=max_len,page=current_page))
from loader import dp, photo_db @dp.callback_query_handler(place_callback.filter(item_name="sov_r")) async def sov_region_pag(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) text = get_page(Sovet_text) photo = get_page(Sovet_photo) await call.message.answer_photo( photo=open(photo_db.get_one_file_name(name=photo), 'rb'), reply_markup=get_page_keyboard(k="sov", max=max_sov)) await call.message.answer(text=text, reply_markup=get_text(max=max_sov, k="sov_t")) @dp.callback_query_handler(pagination_call.filter(key="sov")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page = int(callback_data.get("page")) photo = get_page(array=Sovet_photo, page=current_page) media = InputMediaPhoto(media=open(photo_db.get_one_file_name( name=photo), 'rb')) markup = get_page_keyboard(k="sov", max=max_sov, page=current_page) await call.message.edit_media(media=media, reply_markup=markup) @dp.callback_query_handler(pagination_call.filter(key="sov_t")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page = int(callback_data.get("page")) text = get_page(array=Sovet_text, page=current_page)
from handlers.users.encyclopedia import get_page from keyboards.inline.callback_datas import place_callback, pagination_call from keyboards.inline.encyclopedia import get_page_keyboard, get_text from loader import dp, photo_db @dp.callback_query_handler(place_callback.filter(item_name="rai_r")) async def rai_region_pag(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) text= get_page(Railway_text) photo=get_page(Railway_photo) await call.message.answer_photo(photo=open(photo_db.get_one_file_name(name=photo), 'rb'), reply_markup=get_page_keyboard(k="rai",max=max_rai)) await call.message.answer(text=text, reply_markup=get_text(max=max_rai,k="rai_t")) @dp.callback_query_handler(pagination_call.filter(key="rai")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page=int(callback_data.get("page")) photo = get_page(array=Railway_photo,page=current_page) media=InputMediaPhoto(media=open(photo_db.get_one_file_name(name=photo),'rb')) markup=get_page_keyboard(k="rai",max=max_rai,page=current_page) await call.message.edit_media(media= media, reply_markup=markup) @dp.callback_query_handler(pagination_call.filter(key="rai_t")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page=int(callback_data.get("page")) text=get_page(array=Railway_text,page=current_page) await call.message.edit_text(text=text, reply_markup=get_text(k="rai_t",max=max_rai,page=current_page))
from keyboards.inline.encyclopedia import choice_p from loader import dp, photo_db @dp.callback_query_handler(text="cancel_place") async def cancel_encyclopedia(call: CallbackQuery): await call.answer(text="Отмена", show_alert=True) # Отправляем пустую клавиатуру, т.е. выходит из клавиатуры await call.message.edit_reply_markup(reply_markup=None) @dp.message_handler(Command("encyclopedia")) async def kir_reg(message: types.Message): await message.answer( text=f"Выберите район\n" "Если передумали - нажмите отмена", # choice - клавиатура reply_markup=choice_p) @dp.callback_query_handler(pagination_call.filter(page="current_page")) async def cur_p(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=60) def get_page(array, page: int = 1): page_index = page - 1 return array[page_index]
from keyboards.inline.callback_datas import place_callback, pagination_call from keyboards.inline.encyclopedia import get_text, get_page_keyboard from loader import dp, photo_db @dp.callback_query_handler(place_callback.filter(item_name="prol_r")) async def prol_region_pag(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) text= get_page(Proletarian_text) photo=get_page(Proletarian_photo) await call.message.answer_photo(photo=open(photo_db.get_one_file_name(name=photo), 'rb'), reply_markup=get_page_keyboard(k="prol",max=max_prol)) await call.message.answer(text=text, reply_markup=get_text(max=max_prol,k="prol_t")) @dp.callback_query_handler(pagination_call.filter(key="prol")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page=int(callback_data.get("page")) photo = get_page(array=Proletarian_photo,page=current_page) media=InputMediaPhoto(media=open(photo_db.get_one_file_name(name=photo),'rb')) markup=get_page_keyboard(k="prol",max=max_prol,page=current_page) await call.message.edit_media(media= media, reply_markup=markup) @dp.callback_query_handler(pagination_call.filter(key="prol_t")) async def show_current_page(call: CallbackQuery, callback_data: dict): await call.answer(cache_time=2) current_page=int(callback_data.get("page")) text=get_page(array=Proletarian_text,page=current_page) await call.message.edit_text(text=text, reply_markup=get_text(k="prol_t",max=max_prol,page=current_page))