Update Votekick first part comment

This commit is contained in:
adator85
2025-08-16 02:27:03 +02:00
parent 3fc49e9069
commit f5212deacf
2 changed files with 22 additions and 11 deletions

View File

@@ -2,7 +2,7 @@
''' '''
from threading import Timer, Thread, RLock from threading import Timer, Thread, RLock
from socket import socket from socket import socket
from typing import Any from typing import Any, Optional
class Settings: class Settings:
"""This Class will never be reloaded. """This Class will never be reloaded.
@@ -37,7 +37,7 @@ class Settings:
""" """
self.__CACHE[key] = value_to_cache 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""" """It returns the value associated to the key and finally it removes the entry"""
if self.__CACHE.get(key): if self.__CACHE.get(key):
return self.__CACHE.pop(key) return self.__CACHE.pop(key)

View File

@@ -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 from typing import TYPE_CHECKING, Any
import re import re
from dataclasses import dataclass, field from dataclasses import dataclass, field
import mods.votekick.votekick_manager
if TYPE_CHECKING: if TYPE_CHECKING:
from core.irc import Irc 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 @dataclass
class VoteChannelModel: class VoteChannelModel:
@@ -58,6 +61,11 @@ class Votekick():
# Add Utils. # Add Utils.
self.Utils = ircInstance.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 # Créer les nouvelles commandes du module
self.Irc.build_command(1, self.module_name, 'vote', 'The kick vote module') self.Irc.build_command(1, self.module_name, 'vote', 'The kick vote module')
@@ -106,6 +114,9 @@ class Votekick():
def unload(self) -> None: def unload(self) -> None:
try: 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: for chan in self.VOTE_CHANNEL_DB:
self.Protocol.send_part_chan(uidornickname=self.Config.SERVICE_ID, channel=chan.channel_name) self.Protocol.send_part_chan(uidornickname=self.Config.SERVICE_ID, channel=chan.channel_name)