Initialize a ProxyManager instance with a proxy string and perform proxy checks. Args: botright: An instance of Botright for linking purposes. proxy (str): The proxy string to be managed and checked.
(self, botright, proxy: str)
| 35 | timezone: str = "" |
| 36 | |
| 37 | async def __ainit__(self, botright, proxy: str) -> None: |
| 38 | """ |
| 39 | Initialize a ProxyManager instance with a proxy string and perform proxy checks. |
| 40 | |
| 41 | Args: |
| 42 | botright: An instance of Botright for linking purposes. |
| 43 | proxy (str): The proxy string to be managed and checked. |
| 44 | """ |
| 45 | link(self, botright) |
| 46 | |
| 47 | self.proxy = proxy.strip() if proxy else "" |
| 48 | |
| 49 | self.timeout = httpx.Timeout(20.0, read=None) |
| 50 | self._httpx = httpx.AsyncClient(verify=False) |
| 51 | |
| 52 | if self.proxy: |
| 53 | self.split_proxy() |
| 54 | self.proxy = f"{self.username}:{self.password}@{self.ip}:{self.port}" if self.username else f"{self.ip}:{self.port}" |
| 55 | self.plain_proxy = f"http://{self.proxy}" |
| 56 | self._phttpx = httpx.AsyncClient(proxies={"all://": self.plain_proxy}, verify=False) |
| 57 | self.http_proxy = {"http": self.plain_proxy, "https": self.plain_proxy} |
| 58 | |
| 59 | if self.username: |
| 60 | self.browser_proxy = {"server": f"{self.ip}:{self.port}", "username": self.username, "password": self.password} |
| 61 | else: |
| 62 | self.browser_proxy = {"server": self.plain_proxy} |
| 63 | |
| 64 | await self.check_proxy(self._phttpx) |
| 65 | |
| 66 | else: |
| 67 | self._phttpx = self._httpx |
| 68 | await self.check_proxy(self._phttpx) |
| 69 | |
| 70 | async def __adel__(self) -> None: |
| 71 | await self._httpx.aclose() |
nothing calls this directly
no test coverage detected