MCPcopy Create free account
hub / github.com/HiddenCodeDevs/BlumTelegramBot / check_proxy

Function check_proxy

bot/utils/checkers.py:9–20  ·  view source on GitHub ↗
(http_client: ClientSession)

Source from the content-addressed store, hash-verified

7from bot.utils.logger import logger
8
9async def check_proxy(http_client: ClientSession) -> str | None:
10 try:
11 response = await http_client.get(url='https://api.ipify.org?format=json', timeout=ClientTimeout(5))
12 data = await response.json()
13 if data and data.get('ip'):
14 return data.get('ip')
15 except (ConnectionRefusedError, ClientProxyConnectionError, CancelledError):
16 logger.trace(f"Proxy not available")
17 except ProxyError as e:
18 logger.error(f"The proxy type may be incorrect! Error: {type(e).__name__}: {e}")
19 except Exception as e:
20 logger.error(f"{traceback.format_exc()}")
21
22
23async def wait_proxy(http_client: ClientSession, time_between_checks_sec: int = 5) -> str | None:

Callers 2

runMethod · 0.90
wait_proxyFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected