diff --git a/core/classes/settings.py b/core/classes/settings.py index c37a37b..57d5d13 100644 --- a/core/classes/settings.py +++ b/core/classes/settings.py @@ -2,7 +2,7 @@ ''' from threading import Timer, Thread, RLock from socket import socket -from typing import Any +from typing import Any, Optional class Settings: """This Class will never be reloaded. @@ -37,7 +37,7 @@ class Settings: """ self.__CACHE[key] = value_to_cache - def get_cache(self, key) -> Any: + def get_cache(self, key) -> Optional[Any]: """It returns the value associated to the key and finally it removes the entry""" if self.__CACHE.get(key): return self.__CACHE.pop(key) diff --git a/mods/votekick/mod_votekick.py b/mods/votekick/mod_votekick.py index eb3c355..b3ac388 100644 --- a/mods/votekick/mod_votekick.py +++ b/mods/votekick/mod_votekick.py @@ -1,20 +1,23 @@ +''' + File : mod_votekick.py + Version : 1.0.0 + Description : Manages votekick sessions for multiple channels. + Handles activation, ongoing vote checks, and cleanup. + Author : adator + Created : 2025-08-16 + Last Updated: 2025-08-16 +----------------------------------------- +''' from typing import TYPE_CHECKING, Any import re from dataclasses import dataclass, field +import mods.votekick.votekick_manager if TYPE_CHECKING: from core.irc import Irc -# Activer le systeme sur un salon (activate #salon) -# Le service devra se connecter au salon -# Le service devra se mettre en op -# Soumettre un nom de user (submit nickname) -# voter pour un ban (vote_for) -# voter contre un ban (vote_against) - - -class Votekick(): +class Votekick: @dataclass class VoteChannelModel: @@ -58,6 +61,11 @@ class Votekick(): # Add Utils. self.Utils = ircInstance.Utils + metadata = ircInstance.Loader.Settings.get_cache('VOTEKICK') + + if metadata is not None: + self.VOTE_CHANNEL_DB = metadata + # Créer les nouvelles commandes du module self.Irc.build_command(1, self.module_name, 'vote', 'The kick vote module') @@ -106,6 +114,9 @@ class Votekick(): def unload(self) -> None: try: + # Cache the local DB with current votes. + self.Loader.Settings.set_cache('VOTEKICK', self.VOTE_CHANNEL_DB) + for chan in self.VOTE_CHANNEL_DB: self.Protocol.send_part_chan(uidornickname=self.Config.SERVICE_ID, channel=chan.channel_name)