From a023d966fbe680d8aa7830acfb90da38499c5890 Mon Sep 17 00:00:00 2001 From: dromanov Date: Fri, 5 Jul 2024 23:59:01 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20bug=20fix=20in=20admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/dating/create_forms_funcs.py | 15 +++++++++++++-- handlers/admins/monitoring.py | 13 +++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/functions/dating/create_forms_funcs.py b/functions/dating/create_forms_funcs.py index c6ce1f42..9eecceb3 100644 --- a/functions/dating/create_forms_funcs.py +++ b/functions/dating/create_forms_funcs.py @@ -4,6 +4,7 @@ Optional, ) +from aiogram.dispatcher import FSMContext from aiogram.types import ( CallbackQuery, ) @@ -49,9 +50,19 @@ async def create_questionnaire_reciprocity( await send_questionnaire(chat_id=chat_id, add_text=add_text, owner_id=liker) -async def monitoring_questionnaire(call: CallbackQuery) -> None: +async def monitoring_questionnaire(call: CallbackQuery, state: FSMContext) -> None: telegram_id = call.from_user.id - user_list = await get_next_user(telegram_id, monitoring=True) + storage = await state.get_data() + user_offsets = storage.get("user_offsets", dict()) + user_limits = storage.get("user_limits", dict()) + offset = user_offsets.get(telegram_id, 0) + limit = user_limits.get(telegram_id, 10000) + user_list = await get_next_user(telegram_id, monitoring=True, offset=offset, limit=limit) + + if user_list: + user_offsets[telegram_id] = offset + len(user_list) + user_limits[telegram_id] = limit + 100 + await state.update_data(user_offsets=user_offsets) random_user = random.choice(user_list) await bot.edit_message_reply_markup( chat_id=call.from_user.id, message_id=call.message.message_id diff --git a/handlers/admins/monitoring.py b/handlers/admins/monitoring.py index 3f874bb0..06096b6b 100644 --- a/handlers/admins/monitoring.py +++ b/handlers/admins/monitoring.py @@ -1,6 +1,7 @@ from aiogram import ( types, ) +from aiogram.dispatcher import FSMContext from filters.IsAdminFilter import ( IsAdmin, @@ -32,22 +33,22 @@ async def admin_monitoring(message: types.Message) -> None: @dp.callback_query_handler(text="confirm_send_monitoring") -async def confirm_send_monitoring(call: types.CallbackQuery) -> None: +async def confirm_send_monitoring(call: types.CallbackQuery, state: FSMContext) -> None: try: - await monitoring_questionnaire(call) + await monitoring_questionnaire(call, state) except IndexError: pass # FIXME: мониторинг: IndexError @dp.callback_query_handler(action_keyboard_monitoring.filter(action="ban")) -async def ban_form_owner(call: types.CallbackQuery) -> None: +async def ban_form_owner(call: types.CallbackQuery, state: FSMContext) -> None: target_id = call.data.split(":")[2] await db_commands.update_user_data(telegram_id=target_id, is_banned=True) await call.answer(_("Анкета пользователя была заблокирована")) - await monitoring_questionnaire(call) + await monitoring_questionnaire(call, state) @dp.callback_query_handler(action_keyboard_monitoring.filter(action="next")) -async def next_form_owner(call: types.CallbackQuery) -> None: - await monitoring_questionnaire(call) +async def next_form_owner(call: types.CallbackQuery, state: FSMContext) -> None: + await monitoring_questionnaire(call, state)