Fix Channel update, adding group-security

core/Model.py:
    - Adding a new method => delete_user_from_all_channel
mods/mod_defender.py:
    - adding 2 options => reputation_score_after_release and reputation_sg (for security-group)
    - moving show_users command to Irc.py
    - Reputation:
        - delete user from all channels when the user is killed
        - now when the reputation is updated by an IRCop the service will not trigger the ip scan, and it will update the reputation
        - The reputation DB is now filled out by the User Object
        - When a suspect user decide to join a new channel, the service will force the user to quit this channel
        - When the suspect change his nickname the service will not unban and ban again the user except if the ban_all_chan option is activated
        - After the release, the reputation is changed by the reputation_score_after_release instead of reputation_seuil + 1
        - When the reputation is activated, the service will put +b sg: unknow-users and +e: other groups
        - adding score after release and security-group dynamic command. the user will be able to activate them
core/irc.py:
    - Adding some exceptions to catch erros when user want to load a module
    - reputation update.
    - When a user quit, the service will delete the user from all channels
    - Fix the Channel Object, when a security group this will create errors in the UIDs in the channel Object
    - adding show_admins command
This commit is contained in:
adator
2024-08-24 01:18:31 +02:00
parent 933509b1b6
commit 637cd7e9d2
4 changed files with 185 additions and 114 deletions

View File

@@ -275,9 +275,19 @@ class Channel:
@dataclass
class ChannelModel:
name: str
"""### Channel name
It include the #"""
uids: list
"""### List of UID available in the channel
including their modes ~ @ % + *
Returns:
list: The list of UID's including theirs modes
"""
UID_CHANNEL_DB: list[ChannelModel] = []
"""List that contains all the Channels objects (ChannelModel)
"""
def __init__(self, Base: Base) -> None:
self.log = Base.logs
@@ -362,6 +372,26 @@ class Channel:
except ValueError as ve:
self.log.error(f'{ve}')
def delete_user_from_all_channel(self, uid:str) -> bool:
try:
result = False
for record in self.UID_CHANNEL_DB:
for user_id in record.uids:
if self.Base.clean_uid(user_id) == self.Base.clean_uid(uid):
record.uids.remove(user_id)
self.log.debug(f'The UID {uid} has been removed, here is the new object: {record}')
result = True
for record in self.UID_CHANNEL_DB:
if not record.uids:
self.UID_CHANNEL_DB.remove(record)
self.log.debug(f'The Channel {record.name} has been removed, here is the new object: {record}')
return result
except ValueError as ve:
self.log.error(f'{ve}')
def get_Channel(self, name: str) -> Union[ChannelModel, None]:
Channel = None