mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-20 02:26:32 +01:00
httpx man
This commit is contained in:
parent
db634f2a73
commit
a6f2055b8c
1 changed files with 19 additions and 22 deletions
|
@ -855,18 +855,15 @@ class OtherCog(commands.Cog):
|
||||||
await ctx.respond("Removed domain from blacklist.")
|
await ctx.respond("Removed domain from blacklist.")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def check_proxy(self, url: str = "socks5://localhost:1090"):
|
async def check_proxy(url: str = "socks5://localhost:1090"):
|
||||||
async with httpx.AsyncClient(
|
client = httpx.AsyncClient(http2=True)
|
||||||
http2=True
|
|
||||||
) as client:
|
|
||||||
my_ip64 = (await client.get("https://api64.ipify.org")).text
|
my_ip64 = (await client.get("https://api64.ipify.org")).text
|
||||||
my_ip4 = (await client.get("https://api.ipify.org")).text
|
my_ip4 = (await client.get("https://api.ipify.org")).text
|
||||||
real_ips = [my_ip64, my_ip4]
|
real_ips = [my_ip64, my_ip4]
|
||||||
|
await client.aclose()
|
||||||
|
|
||||||
# Check the proxy
|
# Check the proxy
|
||||||
with httpx.AsyncClient(
|
client = httpx.AsyncClient(http2=True, proxies=url)
|
||||||
proxies=url
|
|
||||||
) as client:
|
|
||||||
try:
|
try:
|
||||||
response = await client.get(
|
response = await client.get(
|
||||||
"https://1.1.1.1/cdn-cgi/trace",
|
"https://1.1.1.1/cdn-cgi/trace",
|
||||||
|
@ -878,7 +875,7 @@ class OtherCog(commands.Cog):
|
||||||
return 1
|
return 1
|
||||||
except (httpx.TransportError, httpx.HTTPStatusError):
|
except (httpx.TransportError, httpx.HTTPStatusError):
|
||||||
return 2
|
return 2
|
||||||
|
await client.aclose()
|
||||||
|
|
||||||
@commands.slash_command(name="yt-dl")
|
@commands.slash_command(name="yt-dl")
|
||||||
@commands.max_concurrency(1, commands.BucketType.user)
|
@commands.max_concurrency(1, commands.BucketType.user)
|
||||||
|
|
Loading…
Reference in a new issue