karkas/src/modules/Roles.py
Armatik 7f232eff50 Добавлены новые модули.
- Config.py Модуль взаимодействия с config.yaml
- Roles.py Модуль проверки прав доступа пользователя.
2023-10-27 16:30:43 +03:00

34 lines
1000 B
Python

from Config import Config
from DataBase import DataBase
class Roles:
def __init__(self):
self.DB = DataBase()
self.Config = Config()
self.user_role_name = self.Config.get_roles()['USER']
self.moderator_role_name = self.Config.get_roles()['MODERATOR']
self.admin_role_name = self.Config.get_roles()['ADMIN']
async def check_admin_permission(self, user_id):
if await self.DB.get_user_role(user_id) == 2:
return True
else:
return False
async def check_moderator_permission(self, user_id):
if await self.DB.get_user_role(user_id) == 1:
return True
else:
return False
async def get_role_name(self, role_number):
if role_number == 0:
return self.user_role_name
elif role_number == 1:
return self.moderator_role_name
elif role_number == 2:
return self.admin_role_name
else:
return None