mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 11:14:23 +00:00
Adding current_admin to the global settings:
- New property current_admin added to the Settings.py
- Fix also translation function
This commit is contained in:
@@ -69,7 +69,7 @@ def rehash_service(uplink: 'Irc', nickname: str) -> None:
|
||||
msg=f'[REHASH] Module [{mod}] reloaded',
|
||||
channel=uplink.Config.SERVICE_CHANLOG
|
||||
)
|
||||
|
||||
uplink.Utils = sys.modules['core.utils']
|
||||
uplink.Config = uplink.Loader.ConfModule.Configuration(uplink.Loader).get_config_model()
|
||||
uplink.Config.HSID = config_model_bakcup.HSID
|
||||
uplink.Config.DEFENDER_INIT = config_model_bakcup.DEFENDER_INIT
|
||||
|
||||
@@ -4,10 +4,11 @@ from logging import Logger
|
||||
from threading import Timer, Thread, RLock
|
||||
from socket import socket
|
||||
from typing import Any, Optional, TYPE_CHECKING
|
||||
from core.definition import MSModule
|
||||
from core.definition import MSModule, MAdmin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.classes.user import User
|
||||
from core.classes.admin import Admin
|
||||
|
||||
class Settings:
|
||||
"""This Class will never be reloaded.
|
||||
@@ -15,33 +16,36 @@ class Settings:
|
||||
the whole life of the app
|
||||
"""
|
||||
|
||||
RUNNING_TIMERS: list[Timer] = []
|
||||
RUNNING_THREADS: list[Thread] = []
|
||||
RUNNING_SOCKETS: list[socket] = []
|
||||
PERIODIC_FUNC: dict[object] = {}
|
||||
LOCK: RLock = RLock()
|
||||
RUNNING_TIMERS: list[Timer] = []
|
||||
RUNNING_THREADS: list[Thread] = []
|
||||
RUNNING_SOCKETS: list[socket] = []
|
||||
PERIODIC_FUNC: dict[object] = {}
|
||||
LOCK: RLock = RLock()
|
||||
|
||||
CONSOLE: bool = False
|
||||
CONSOLE: bool = False
|
||||
|
||||
MAIN_SERVER_HOSTNAME: str = None
|
||||
PROTOCTL_USER_MODES: list[str] = []
|
||||
PROTOCTL_PREFIX: list[str] = []
|
||||
MAIN_SERVER_HOSTNAME: str = None
|
||||
PROTOCTL_USER_MODES: list[str] = []
|
||||
PROTOCTL_PREFIX: list[str] = []
|
||||
|
||||
SMOD_MODULES: list[MSModule] = []
|
||||
SMOD_MODULES: list[MSModule] = []
|
||||
"""List contains all Server modules"""
|
||||
|
||||
__CACHE: dict[str, Any] = {}
|
||||
__CACHE: dict[str, Any] = {}
|
||||
"""Use set_cache or get_cache instead"""
|
||||
|
||||
__TRANSLATION: dict[str, list[list[str]]] = dict()
|
||||
__TRANSLATION: dict[str, list[list[str]]] = dict()
|
||||
"""Translation Varibale"""
|
||||
|
||||
__LANG: str = "EN"
|
||||
__LANG: str = "EN"
|
||||
|
||||
__INSTANCE_OF_USER_UTILS: Optional['User'] = None
|
||||
__INSTANCE_OF_USER_UTILS: Optional['User'] = None
|
||||
"""Instance of the User Utils class"""
|
||||
|
||||
__LOGGER: Optional[Logger] = None
|
||||
__CURRENT_ADMIN: Optional['MAdmin'] = None
|
||||
"""The Current Admin Object Model"""
|
||||
|
||||
__LOGGER: Optional[Logger] = None
|
||||
"""Instance of the logger"""
|
||||
|
||||
def set_cache(self, key: str, value_to_cache: Any):
|
||||
@@ -97,6 +101,14 @@ class Settings:
|
||||
def global_user(self, user_utils_instance: 'User') -> None:
|
||||
self.__INSTANCE_OF_USER_UTILS = user_utils_instance
|
||||
|
||||
@property
|
||||
def current_admin(self) -> MAdmin:
|
||||
return self.__CURRENT_ADMIN
|
||||
|
||||
@current_admin.setter
|
||||
def current_admin(self, current_admin: MAdmin) -> None:
|
||||
self.__CURRENT_ADMIN = current_admin
|
||||
|
||||
@property
|
||||
def global_logger(self) -> Logger:
|
||||
return self.__LOGGER
|
||||
|
||||
Reference in New Issue
Block a user