Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: add action limit custumize ability #91

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ class EnvFile(BaseSettings):
MARZBAN_PASSWORD: str
MARZBAN_ADDRESS: str
EXCLUDED_MONITORINGS: list[str] = []
ACTION_LIMIT: int = 25
4 changes: 2 additions & 2 deletions utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion utils/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ 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.
"""
Expand Down
Loading