Skip to content

Commit

Permalink
fix #50
Browse files Browse the repository at this point in the history
  • Loading branch information
houshmand-2005 committed Jun 3, 2024
1 parent c15a58c commit a55630c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
2 changes: 2 additions & 0 deletions telegram_bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ async def show_special_limit_function(
if out_put:
for user in out_put:
await update.message.reply_html(text=user)
else:
await update.message.reply_html(text="No special limit found!")


async def set_country_code(update: Update, _context: ContextTypes.DEFAULT_TYPE):
Expand Down
46 changes: 24 additions & 22 deletions utils/panel_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,31 @@ async def get_token(panel_data: PanelType) -> PanelType | ValueError:
"username": f"{panel_data.panel_username}",
"password": f"{panel_data.panel_password}",
}
for scheme in ["https", "http"]:
url = f"{scheme}://{panel_data.panel_domain}/api/admin/token"
try:
async with httpx.AsyncClient(verify=False) as client:
response = await client.post(url, data=payload, timeout=5)
response.raise_for_status()
json_obj = response.json()
panel_data.panel_token = json_obj["access_token"]
return panel_data
except httpx.HTTPStatusError:
message = f"[{response.status_code}] {response.text}"
await send_logs(message)
logger.error(message)
continue
except SSLError:
continue
except Exception as error: # pylint: disable=broad-except
message = f"An unexpected error occurred: {error}"
await send_logs(message)
logger.error(message)
continue
for attempt in range(10):
for scheme in ["https", "http"]:
url = f"{scheme}://{panel_data.panel_domain}/api/admin/token"
try:
async with httpx.AsyncClient(verify=False) as client:
response = await client.post(url, data=payload, timeout=5)
response.raise_for_status()
json_obj = response.json()
panel_data.panel_token = json_obj["access_token"]
return panel_data
except httpx.HTTPStatusError:
message = f"[{response.status_code}] {response.text}"
await send_logs(message)
logger.error(message)
continue
except SSLError:
continue
except Exception as error: # pylint: disable=broad-except
message = f"An unexpected error occurred: {error}"
await send_logs(message)
logger.error(message)
continue
await asyncio.sleep(5 * attempt)
message = (
"Failed to get token. make sure the panel is running "
"Failed to get token after 10 attempts. Make sure the panel is running "
+ "and the username and password are correct."
)
await send_logs(message)
Expand Down
2 changes: 1 addition & 1 deletion v2iplimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from utils.read_config import read_config
from utils.types import PanelType

VERSION = "1.0.4.1"
VERSION = "1.0.4.2"

parser = argparse.ArgumentParser(description="Help message")
parser.add_argument("--version", action="version", version=VERSION)
Expand Down

0 comments on commit a55630c

Please sign in to comment.