From 9cd089ee6e95c1fdb4d1473236086f33ea324413 Mon Sep 17 00:00:00 2001 From: adator <85586985+adator85@users.noreply.github.com> Date: Wed, 28 Aug 2024 00:50:50 +0200 Subject: [PATCH] Fix some issues --- core/installation.py | 2 +- core/loadConf.py | 23 ++++++++++++++--------- mods/mod_clone.py | 2 ++ mods/mod_defender.py | 1 - 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/installation.py b/core/installation.py index c0ea795..5708269 100644 --- a/core/installation.py +++ b/core/installation.py @@ -62,7 +62,7 @@ class Install: defender_install_folder=defender_install_folder, venv_folder=venv_folder, venv_cmd_installation=['python3', '-m', 'venv', venv_folder], - venv_cmd_requirements=['sqlalchemy','psutil','requests'], + venv_cmd_requirements=['sqlalchemy','psutil','requests','faker'], venv_pip_executable=f'{os.path.join(defender_install_folder, venv_folder, "bin")}{os.sep}pip', venv_python_executable=f'{os.path.join(defender_install_folder, venv_folder, "bin")}{os.sep}python' ) diff --git a/core/loadConf.py b/core/loadConf.py index 49ed1a6..79557b7 100644 --- a/core/loadConf.py +++ b/core/loadConf.py @@ -1,4 +1,4 @@ -import json +import json, sys from os import sep from typing import Union from dataclasses import dataclass, field @@ -72,16 +72,21 @@ class Config: return None def __load_json_service_configuration(self): + try: + conf_filename = f'core{sep}configuration.json' + with open(conf_filename, 'r') as configuration_data: + configuration:dict[str, Union[str, int, list, dict]] = json.load(configuration_data) - conf_filename = f'core{sep}configuration.json' - with open(conf_filename, 'r') as configuration_data: - configuration:dict[str, Union[str, int, list, dict]] = json.load(configuration_data) + for key, value in configuration['CONFIG_COLOR'].items(): + configuration['CONFIG_COLOR'][key] = str(value).encode('utf-8').decode('unicode_escape') + + return configuration + + except FileNotFoundError as fe: + print(f'FileNotFound: {fe}') + print('Configuration file not found please create core/configuration.json') + sys.exit(0) - for key, value in configuration['CONFIG_COLOR'].items(): - configuration['CONFIG_COLOR'][key] = str(value).encode('utf-8').decode('unicode_escape') - - return configuration - def __load_service_configuration(self) -> ConfigDataModel: import_config = self.__load_json_service_configuration() diff --git a/mods/mod_clone.py b/mods/mod_clone.py index 0b283a6..81c16fa 100644 --- a/mods/mod_clone.py +++ b/mods/mod_clone.py @@ -208,10 +208,12 @@ class Clone(): if clone_name.lower() == 'all': for clone in self.ModConfig.clone_nicknames: self.Irc.send2socket(f':{dnickname} PRIVMSG {clone} :KILL') + self.ModConfig.clone_nicknames.remove(clone) else: for clone in self.ModConfig.clone_nicknames: if clone_name == clone: self.Irc.send2socket(f':{dnickname} PRIVMSG {clone} :KILL') + self.ModConfig.clone_nicknames.remove(clone) except Exception as err: self.Logs.error(f'{err}') diff --git a/mods/mod_defender.py b/mods/mod_defender.py index 7de45bf..a1da1c2 100644 --- a/mods/mod_defender.py +++ b/mods/mod_defender.py @@ -4,7 +4,6 @@ from typing import Union import re, socket, psutil, requests, json, time from sys import exit from core.irc import Irc -from test import Test # Le module crée devra réspecter quelques conditions # 1. Le nom de la classe devra toujours s'appeler comme le module. Exemple => nom de class Defender | nom du module mod_defender