its-matrix-bot/its_matrix_bot/its_api.py
2022-03-27 19:35:40 +02:00

26 lines
735 B
Python

import aiohttp
from .config import Config
class ItSyndikatApi:
base_url: str
config: Config
def __init__(self, config: Config):
self.base_url = "https://it-syndikat.org/api/"
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:
async with session.post(
self.base_url + "ping.php", params=params
) as response:
await response.text()