Add auto unban functionality and update related tests and dependencies

This commit is contained in:
2025-08-27 20:56:22 +03:00
parent 748670816f
commit 86b6903920
9 changed files with 737 additions and 48 deletions

View File

@@ -11,6 +11,7 @@ if CURRENT_DIR not in sys.path:
from helper_bot.main import start_bot
from helper_bot.utils.base_dependency_factory import get_global_instance
from helper_bot.server_monitor import ServerMonitor
from helper_bot.utils.auto_unban_scheduler import get_auto_unban_scheduler
async def start_monitoring(bdf, bot):
@@ -40,6 +41,11 @@ async def main():
# Создаем экземпляр монитора
monitor = await start_monitoring(bdf, monitor_bot)
# Инициализируем планировщик автоматического разбана
auto_unban_scheduler = get_auto_unban_scheduler()
auto_unban_scheduler.set_bot(monitor_bot)
auto_unban_scheduler.start_scheduler()
# Флаг для корректного завершения
shutdown_event = asyncio.Event()
@@ -71,6 +77,9 @@ async def main():
except Exception as e:
print(f"Ошибка при отправке сообщения об отключении: {e}")
print("Останавливаем планировщик автоматического разбана...")
auto_unban_scheduler.stop_scheduler()
print("Останавливаем задачи...")
# Отменяем задачи
bot_task.cancel()