its-matrix-bot/its_matrix_bot/its_api.py

27 lines
735 B
Python
Raw Normal View History

2022-03-27 19:17:21 +02:00
import aiohttp
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):
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:
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()