From f42940f84780208d1731214af2bbf6d6bfc28074 Mon Sep 17 00:00:00 2001 From: algizn97 Date: Thu, 11 Sep 2025 10:57:21 +0500 Subject: [PATCH] Added timer deletion button --- app/telegram/Keyboards/inline_keyboards.py | 1 + .../functions/condition_settings/settings.py | 16 +++++++++++++--- logger_helper/logger_helper.py | 2 +- requirements.txt | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/telegram/Keyboards/inline_keyboards.py b/app/telegram/Keyboards/inline_keyboards.py index a954d32..993984d 100644 --- a/app/telegram/Keyboards/inline_keyboards.py +++ b/app/telegram/Keyboards/inline_keyboards.py @@ -196,6 +196,7 @@ def create_close_limit_markup(symbol: str) -> InlineKeyboardMarkup: timer_markup = InlineKeyboardMarkup(inline_keyboard=[ [InlineKeyboardButton(text="Установить таймер", callback_data="clb_set_timer")], + [InlineKeyboardButton(text="Удалить таймер", callback_data="clb_delete_timer")], back_btn_to_main ]) diff --git a/app/telegram/functions/condition_settings/settings.py b/app/telegram/functions/condition_settings/settings.py index c2bfbbe..126eb36 100644 --- a/app/telegram/functions/condition_settings/settings.py +++ b/app/telegram/functions/condition_settings/settings.py @@ -29,7 +29,7 @@ async def main_settings_message(id, message): text = f""" Условия запуска - Режим торговли: {trigger} -- Таймер: установить таймер / остановить таймер +- Таймер: установить таймер / удалить таймер """ await message.answer(text=text, parse_mode='html', reply_markup=inline_markup.condition_settings_markup) @@ -68,7 +68,7 @@ async def timer_message(id, message: Message, state: FSMContext): return await message.answer( - f"Таймер: {timer_info['timer_minutes']} мин\n", + f"Таймер установлен на: {timer_info['timer_minutes']} мин\n", reply_markup=inline_markup.timer_markup ) @@ -76,7 +76,7 @@ async def timer_message(id, message: Message, state: FSMContext): @condition_settings_router.callback_query(F.data == "clb_set_timer") async def set_timer_callback(callback: CallbackQuery, state: FSMContext): await state.set_state(condition_settings.timer) # состояние для ввода времени - await callback.message.answer("Введите время работы в минутах (например, 60):") + await callback.message.answer("Введите время работы в минутах (например, 60):", reply_markup=inline_markup.cancel) await callback.answer() @@ -89,14 +89,24 @@ async def process_timer_input(message: Message, state: FSMContext): return await rq.update_user_timer(message.from_user.id, minutes) + logger.info("Timer set for user %s: %s minutes", message.from_user.id, minutes) await message.answer(f"Таймер установлен на {minutes} минут.\nНажмите кнопку 'Начать торговлю' для запуска.", reply_markup=inline_markup.start_trading_markup) + await state.clear() except ValueError: await message.reply("Пожалуйста, введите корректное число.") +@condition_settings_router.callback_query(F.data == "clb_delete_timer") +async def delete_timer_callback(callback: CallbackQuery, state: FSMContext): + await state.clear() + await rq.update_user_timer(callback.from_user.id, 0) + logger.info("Timer deleted for user %s", callback.from_user.id) + await timer_message(callback.from_user.id, callback.message, state) + await callback.answer() + async def filter_volatility_message(message, state): text = '''Фильтр волатильности diff --git a/logger_helper/logger_helper.py b/logger_helper/logger_helper.py index f28566e..7f17351 100644 --- a/logger_helper/logger_helper.py +++ b/logger_helper/logger_helper.py @@ -80,7 +80,7 @@ LOGGING_CONFIG = { "level": "DEBUG", "propagate": False, }, - "conditions_settings": { + "condition_settings": { "handlers": ["console", "timed_rotating_file"], "level": "DEBUG", "propagate": False, diff --git a/requirements.txt b/requirements.txt index 66baab5..beef837 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,22 +6,40 @@ aiosignal==1.4.0 aiosqlite==0.21.0 annotated-types==0.7.0 attrs==25.3.0 +black==25.1.0 certifi==2025.8.3 charset-normalizer==3.4.3 +click==8.2.1 +colorama==0.4.6 dotenv==0.9.9 +flake8==7.3.0 +flake8-bugbear==24.12.12 +flake8-pie==0.16.0 frozenlist==1.7.0 greenlet==3.2.4 idna==3.10 +isort==6.0.1 magic-filter==1.0.12 +mando==0.7.1 +mccabe==0.7.0 multidict==6.6.4 +mypy_extensions==1.1.0 nest-asyncio==1.6.0 +packaging==25.0 +pathspec==0.12.1 +platformdirs==4.4.0 propcache==0.3.2 pybit==5.11.0 +pycodestyle==2.14.0 pycryptodome==3.23.0 pydantic==2.11.7 pydantic_core==2.33.2 +pyflakes==3.4.0 python-dotenv==1.1.1 +radon==6.0.1 +redis==6.4.0 requests==2.32.5 +six==1.17.0 SQLAlchemy==2.0.43 typing-inspection==0.4.1 typing_extensions==4.14.1