From 984200e77f032edd354e2c529329aad10af9d453 Mon Sep 17 00:00:00 2001 From: Erfan Date: Thu, 7 Nov 2024 03:23:23 +0330 Subject: [PATCH 1/2] improve: add action limit custumize ability --- utils/config.py | 1 + utils/helpers.py | 4 ++-- utils/panel.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/config.py b/utils/config.py index cb795be..50f04fb 100644 --- a/utils/config.py +++ b/utils/config.py @@ -20,3 +20,4 @@ class EnvFile(BaseSettings): MARZBAN_PASSWORD: str MARZBAN_ADDRESS: str EXCLUDED_MONITORINGS: list[str] = [] + ACTION_LIMIT: int = 25 \ No newline at end of file diff --git a/utils/helpers.py b/utils/helpers.py index 02d14be..298bc4b 100644 --- a/utils/helpers.py +++ b/utils/helpers.py @@ -9,7 +9,7 @@ import httpx from marzban import UserModify, UserResponse from models import AdminActions -from utils import logger, panel +from utils import logger, panel, EnvSettings async def create_qr(text: str) -> bytes: @@ -100,7 +100,7 @@ async def manage_panel_inbounds(tag: str, protocol: str, action: AdminActions) - """Manage inbounds for users, processing them in batches and handling updates.""" try: offset = 0 - batch_size = 50 + batch_size = EnvSettings.ACTION_LIMIT while True: users = await panel.get_users(offset) diff --git a/utils/panel.py b/utils/panel.py index bb64283..d69c7b7 100644 --- a/utils/panel.py +++ b/utils/panel.py @@ -117,7 +117,7 @@ async def user_modify(username: str, data: UserModify) -> bool: return False -async def get_users(offset: int = 0, limit: int = 50) -> list[UserResponse]: +async def get_users(offset: int = 0, limit: int = EnvSettings.ACTION_LIMIT) -> list[UserResponse]: """ Retrieve a list of users from the Marzban panel. """ From 257f57a216033eec7050b5371e45d4ac4c513afe Mon Sep 17 00:00:00 2001 From: Erfan Date: Thu, 7 Nov 2024 03:24:54 +0330 Subject: [PATCH 2/2] style: formated code --- utils/config.py | 2 +- utils/panel.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/config.py b/utils/config.py index 50f04fb..7a6b44c 100644 --- a/utils/config.py +++ b/utils/config.py @@ -20,4 +20,4 @@ class EnvFile(BaseSettings): MARZBAN_PASSWORD: str MARZBAN_ADDRESS: str EXCLUDED_MONITORINGS: list[str] = [] - ACTION_LIMIT: int = 25 \ No newline at end of file + ACTION_LIMIT: int = 25 diff --git a/utils/panel.py b/utils/panel.py index d69c7b7..f662227 100644 --- a/utils/panel.py +++ b/utils/panel.py @@ -117,7 +117,9 @@ async def user_modify(username: str, data: UserModify) -> bool: return False -async def get_users(offset: int = 0, limit: int = EnvSettings.ACTION_LIMIT) -> list[UserResponse]: +async def get_users( + offset: int = 0, limit: int = EnvSettings.ACTION_LIMIT +) -> list[UserResponse]: """ Retrieve a list of users from the Marzban panel. """