blob: 28640c6d4d8aad2b72052b2f09f6e0049506eca5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import httpx
from ATRI import conf
from ATRI.log import log
timeout = conf.BotConfig.request_timeout
if timeout:
timeout = httpx.Timeout(timeout)
if not conf.BotConfig.proxy:
proxy = dict()
else:
proxy = {"all://": conf.BotConfig.proxy}
async def get(url: str, **kwargs):
log.debug(f"GET {url} by {proxy if proxy else 'No proxy'} | MORE: \n {kwargs}")
async with httpx.AsyncClient(proxies=proxy, timeout=timeout) as client: # type: ignore
return await client.get(url, **kwargs)
async def post(url: str, **kwargs):
log.debug(f"POST {url} by {proxy if proxy else 'No proxy'} | MORE: \n {kwargs}")
async with httpx.AsyncClient(proxies=proxy, timeout=timeout) as client: # type: ignore
return await client.post(url, **kwargs)
async def delete(url: str, **kwargs):
log.debug(f"DELETE {url} by {proxy if proxy else 'No proxy'} | MORE: \n {kwargs}")
async with httpx.AsyncClient(proxies=proxy, timeout=timeout) as client: # type: ignore
return await client.delete(url, **kwargs)
|