Added PyCharm support to permission module
This commit is contained in:
parent
7d4a28d524
commit
bc8ff7dc0f
0
src/modules/permission/configuration/__init__.py
Normal file
0
src/modules/permission/configuration/__init__.py
Normal file
@ -22,11 +22,11 @@ class PermissionSettings(ConfigurationModelABC):
|
|||||||
|
|
||||||
def from_dict(self, settings: dict):
|
def from_dict(self, settings: dict):
|
||||||
try:
|
try:
|
||||||
for id in settings['AdminRoleIds']:
|
for index in settings['AdminRoleIds']:
|
||||||
self._admin_roles.append(int(id))
|
self._admin_roles.append(int(index))
|
||||||
|
|
||||||
for id in settings['ModeratorRoleIds']:
|
for index in settings['ModeratorRoleIds']:
|
||||||
self._moderator_roles.append(int(id))
|
self._moderator_roles.append(int(index))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
|
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
|
||||||
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||||
|
@ -2,11 +2,10 @@ import discord
|
|||||||
|
|
||||||
from cpl_core.logging import LoggerABC
|
from cpl_core.logging import LoggerABC
|
||||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||||
from modules.permission.configuration.permission_settings import \
|
|
||||||
PermissionSettings
|
|
||||||
from gismo_core.abc.events.on_member_update_abc import OnMemberUpdateABC
|
from gismo_core.abc.events.on_member_update_abc import OnMemberUpdateABC
|
||||||
from gismo_core.abc.events.on_ready_abc import OnReadyABC
|
from gismo_core.abc.events.on_ready_abc import OnReadyABC
|
||||||
from gismo_core.abc.module_abc import ModuleABC
|
from gismo_core.abc.module_abc import ModuleABC
|
||||||
|
from modules.permission.configuration.permission_settings import PermissionSettings
|
||||||
|
|
||||||
|
|
||||||
class Permission(ModuleABC, OnReadyABC, OnMemberUpdateABC):
|
class Permission(ModuleABC, OnReadyABC, OnMemberUpdateABC):
|
||||||
@ -21,7 +20,7 @@ class Permission(ModuleABC, OnReadyABC, OnMemberUpdateABC):
|
|||||||
|
|
||||||
ModuleABC.__init__(
|
ModuleABC.__init__(
|
||||||
self,
|
self,
|
||||||
{ OnReadyABC: 1, OnMemberUpdateABC: 0 },
|
{OnReadyABC: 1, OnMemberUpdateABC: 0},
|
||||||
PermissionSettings
|
PermissionSettings
|
||||||
)
|
)
|
||||||
self._logger.info(__name__, f'Module {type(self)} loaded')
|
self._logger.info(__name__, f'Module {type(self)} loaded')
|
||||||
|
@ -14,13 +14,13 @@ class PermissionService(PermissionServiceABC):
|
|||||||
self._bot = bot
|
self._bot = bot
|
||||||
self._config = config
|
self._config = config
|
||||||
|
|
||||||
self._admin_role_ids: dict[str, list[int]] = {}
|
self._admin_role_ids: dict[int, list[int]] = {}
|
||||||
self._admin_roles: dict[list[discord.Role]] = {}
|
self._admin_roles: dict[int, list[discord.Role]] = {}
|
||||||
self._admins: dict[list[discord.Member]] = {}
|
self._admins: dict[int, list[discord.Member]] = {}
|
||||||
|
|
||||||
self._moderator_role_ids: dict[list[int]] = {}
|
self._moderator_role_ids: dict[int, list[int]] = {}
|
||||||
self._moderator_roles: dict[list[discord.Role]] = {}
|
self._moderator_roles: dict[int, list[discord.Role]] = {}
|
||||||
self._moderators: dict[list[discord.Member]] = {}
|
self._moderators: dict[int, list[discord.Member]] = {}
|
||||||
|
|
||||||
def on_ready(self):
|
def on_ready(self):
|
||||||
for guild in self._bot.guilds:
|
for guild in self._bot.guilds:
|
||||||
@ -60,7 +60,6 @@ class PermissionService(PermissionServiceABC):
|
|||||||
mods.append(member)
|
mods.append(member)
|
||||||
self._logger.trace(__name__, f'Added moderator {member}')
|
self._logger.trace(__name__, f'Added moderator {member}')
|
||||||
|
|
||||||
|
|
||||||
self._admin_roles[guild.id] = admin_roles
|
self._admin_roles[guild.id] = admin_roles
|
||||||
self._admins[guild.id] = admins
|
self._admins[guild.id] = admins
|
||||||
self._moderator_roles[guild.id] = mod_roles
|
self._moderator_roles[guild.id] = mod_roles
|
||||||
@ -87,7 +86,6 @@ class PermissionService(PermissionServiceABC):
|
|||||||
self._moderators[g_id].append(after)
|
self._moderators[g_id].append(after)
|
||||||
self._logger.trace(__name__, f'Added {after.id} to moderators')
|
self._logger.trace(__name__, f'Added {after.id} to moderators')
|
||||||
|
|
||||||
|
|
||||||
def get_admin_role_ids(self, g_id: int) -> list[int]:
|
def get_admin_role_ids(self, g_id: int) -> list[int]:
|
||||||
return self._admin_role_ids[g_id]
|
return self._admin_role_ids[g_id]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user