mirror of
https://gitflic.ru/project/alt-gnome/karkas.git
synced 2025-04-04 08:33:49 +03:00
- Config.py Модуль взаимодействия с config.yaml - Roles.py Модуль проверки прав доступа пользователя.
34 lines
1000 B
Python
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
|