mirror of
https://github.com/MrSedan/neuro-reply-bot-reworked.git
synced 2026-01-14 21:49:42 +03:00
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from aiohttp import ClientSession
|
|
|
|
from neuroapi.types import Admin as AdminType
|
|
|
|
from .api_method import ApiMethod
|
|
|
|
|
|
class Admin(ApiMethod):
|
|
"""Class for admin methods"""
|
|
async def get(self):
|
|
"""
|
|
Asynchronous function to retrieve data from the specified API endpoint and return a list of admins.
|
|
:return List[Admin]
|
|
"""
|
|
async with ClientSession() as session:
|
|
response = await session.get(self.api_url+'/admin/get')
|
|
return [AdminType.from_dict(admin) for admin in await response.json()]
|
|
|
|
async def is_admin(self, id: str):
|
|
"""
|
|
Asynchronous function to check if the user with the given ID is an admin.
|
|
|
|
Args:
|
|
id (str): The ID of the user to be checked.
|
|
|
|
Returns:
|
|
bool: True if the user is an admin, False otherwise.
|
|
"""
|
|
async with ClientSession() as session:
|
|
response = await session.get(self.api_url+f'/admin/is-admin/{id}')
|
|
if await response.text() == 'false':
|
|
return False
|
|
return True
|