import aiohttp class UserRequests: def __init__(self, API_URL, BOT_TOKEN): self.API_URL = API_URL self.headers = {"Content-Type": "application/json", "X-BOTAUTH": BOT_TOKEN} async def getUser(self, user_id): async with aiohttp.ClientSession(self.API_URL, headers=self.headers) as session: # Make sure we have a good connection async with session.head("/") as alive: if alive.status != 200: return None async with session.get(f"/api/user/{user_id}") as data: response = await data.json() return response async def registerUser(self, user_data: dict): async with aiohttp.ClientSession(self.API_URL, headers=self.headers) as session: # Make sure we have a good connection async with session.head("/") as alive: if alive.status != 200: return None async with session.post("/api/user/register", json=user_data) as data: if data.status != 200: return {"status": False} response = await data.json() return response