2022-03-27 19:17:21 +02:00
|
|
|
import aiohttp
|
|
|
|
|
2022-03-27 19:23:42 +02:00
|
|
|
from .config import Config
|
2022-03-27 19:17:21 +02:00
|
|
|
|
2022-03-27 19:35:40 +02:00
|
|
|
|
2022-03-27 19:17:21 +02:00
|
|
|
class ItSyndikatApi:
|
|
|
|
base_url: str
|
|
|
|
config: Config
|
|
|
|
|
|
|
|
def __init__(self, config: Config):
|
2022-08-14 18:34:06 +02:00
|
|
|
self.base_url = "https://spaceapi.it-syndikat.org/api/"
|
2022-03-27 19:17:21 +02:00
|
|
|
self.config = config
|
|
|
|
|
|
|
|
async def status(self):
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
async with session.get(self.base_url + "status.php") as response:
|
|
|
|
return await response.json()
|
|
|
|
|
|
|
|
async def ping(self):
|
|
|
|
params = {"apikey": self.config.spaceping_token}
|
|
|
|
|
|
|
|
async with aiohttp.ClientSession() as session:
|
2022-03-27 19:35:40 +02:00
|
|
|
async with session.post(
|
|
|
|
self.base_url + "ping.php", params=params
|
|
|
|
) as response:
|
2022-03-27 19:17:21 +02:00
|
|
|
await response.text()
|