2
0
forked from kodorvan/stcs

Added timer deletion button

This commit is contained in:
algizn97
2025-09-11 10:57:21 +05:00
parent 3ff146a1b9
commit f42940f847
4 changed files with 33 additions and 4 deletions

View File

@@ -196,6 +196,7 @@ def create_close_limit_markup(symbol: str) -> InlineKeyboardMarkup:
timer_markup = InlineKeyboardMarkup(inline_keyboard=[ timer_markup = InlineKeyboardMarkup(inline_keyboard=[
[InlineKeyboardButton(text="Установить таймер", callback_data="clb_set_timer")], [InlineKeyboardButton(text="Установить таймер", callback_data="clb_set_timer")],
[InlineKeyboardButton(text="Удалить таймер", callback_data="clb_delete_timer")],
back_btn_to_main back_btn_to_main
]) ])

View File

@@ -29,7 +29,7 @@ async def main_settings_message(id, message):
text = f""" <b>Условия запуска</b> text = f""" <b>Условия запуска</b>
<b>- Режим торговли:</b> {trigger} <b>- Режим торговли:</b> {trigger}
<b>- Таймер: </b> установить таймер / остановить таймер <b>- Таймер: </b> установить таймер / удалить таймер
""" """
await message.answer(text=text, parse_mode='html', reply_markup=inline_markup.condition_settings_markup) 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 return
await message.answer( await message.answer(
f"Таймер: {timer_info['timer_minutes']} мин\n", f"Таймер установлен на: {timer_info['timer_minutes']} мин\n",
reply_markup=inline_markup.timer_markup 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") @condition_settings_router.callback_query(F.data == "clb_set_timer")
async def set_timer_callback(callback: CallbackQuery, state: FSMContext): async def set_timer_callback(callback: CallbackQuery, state: FSMContext):
await state.set_state(condition_settings.timer) # состояние для ввода времени 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() await callback.answer()
@@ -89,14 +89,24 @@ async def process_timer_input(message: Message, state: FSMContext):
return return
await rq.update_user_timer(message.from_user.id, minutes) 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Нажмите кнопку 'Начать торговлю' для запуска.", await message.answer(f"Таймер установлен на {minutes} минут.\nНажмите кнопку 'Начать торговлю' для запуска.",
reply_markup=inline_markup.start_trading_markup) reply_markup=inline_markup.start_trading_markup)
await state.clear() await state.clear()
except ValueError: except ValueError:
await message.reply("Пожалуйста, введите корректное число.") 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): async def filter_volatility_message(message, state):
text = '''Фильтр волатильности text = '''Фильтр волатильности

View File

@@ -80,7 +80,7 @@ LOGGING_CONFIG = {
"level": "DEBUG", "level": "DEBUG",
"propagate": False, "propagate": False,
}, },
"conditions_settings": { "condition_settings": {
"handlers": ["console", "timed_rotating_file"], "handlers": ["console", "timed_rotating_file"],
"level": "DEBUG", "level": "DEBUG",
"propagate": False, "propagate": False,

View File

@@ -6,22 +6,40 @@ aiosignal==1.4.0
aiosqlite==0.21.0 aiosqlite==0.21.0
annotated-types==0.7.0 annotated-types==0.7.0
attrs==25.3.0 attrs==25.3.0
black==25.1.0
certifi==2025.8.3 certifi==2025.8.3
charset-normalizer==3.4.3 charset-normalizer==3.4.3
click==8.2.1
colorama==0.4.6
dotenv==0.9.9 dotenv==0.9.9
flake8==7.3.0
flake8-bugbear==24.12.12
flake8-pie==0.16.0
frozenlist==1.7.0 frozenlist==1.7.0
greenlet==3.2.4 greenlet==3.2.4
idna==3.10 idna==3.10
isort==6.0.1
magic-filter==1.0.12 magic-filter==1.0.12
mando==0.7.1
mccabe==0.7.0
multidict==6.6.4 multidict==6.6.4
mypy_extensions==1.1.0
nest-asyncio==1.6.0 nest-asyncio==1.6.0
packaging==25.0
pathspec==0.12.1
platformdirs==4.4.0
propcache==0.3.2 propcache==0.3.2
pybit==5.11.0 pybit==5.11.0
pycodestyle==2.14.0
pycryptodome==3.23.0 pycryptodome==3.23.0
pydantic==2.11.7 pydantic==2.11.7
pydantic_core==2.33.2 pydantic_core==2.33.2
pyflakes==3.4.0
python-dotenv==1.1.1 python-dotenv==1.1.1
radon==6.0.1
redis==6.4.0
requests==2.32.5 requests==2.32.5
six==1.17.0
SQLAlchemy==2.0.43 SQLAlchemy==2.0.43
typing-inspection==0.4.1 typing-inspection==0.4.1
typing_extensions==4.14.1 typing_extensions==4.14.1