Update the version 6

This commit is contained in:
adator
2024-11-11 15:38:38 +01:00
parent 4825775b73
commit bd9713006a
12 changed files with 585 additions and 481 deletions

View File

@@ -721,6 +721,23 @@ class Base:
except TypeError: except TypeError:
return value return value
def convert_to_int(self, value: any) -> Union[int, None]:
"""Convert a value to int
Args:
value (any): Value to convert to int if possible
Returns:
Union[int, None]: Return the int value or None if not possible
"""
try:
response = int(value)
return response
except ValueError:
return None
except TypeError:
return None
def is_valid_ip(self, ip_to_control:str) -> bool: def is_valid_ip(self, ip_to_control:str) -> bool:
try: try:

View File

@@ -46,7 +46,7 @@ class Inspircd:
except AttributeError as ae: except AttributeError as ae:
self.__Base.logs.critical(f"Attribute Error: {ae}") self.__Base.logs.critical(f"Attribute Error: {ae}")
def sendPrivMsg(self, nick_from: str, msg: str, channel: str = None, nick_to: str = None): def send_priv_msg(self, nick_from: str, msg: str, channel: str = None, nick_to: str = None):
"""Sending PRIVMSG to a channel or to a nickname by batches """Sending PRIVMSG to a channel or to a nickname by batches
could be either channel or nickname not both together could be either channel or nickname not both together
Args: Args:
@@ -76,7 +76,7 @@ class Inspircd:
except Exception as err: except Exception as err:
self.__Base.logs.error(f"General Error: {err}") self.__Base.logs.error(f"General Error: {err}")
def sendNotice(self, nick_from: str, nick_to: str, msg: str) -> None: def send_notice(self, nick_from: str, nick_to: str, msg: str) -> None:
"""Sending NOTICE by batches """Sending NOTICE by batches
Args: Args:
@@ -179,7 +179,7 @@ class Inspircd:
self.__Irc.Channel.insert(self.__Irc.Loader.Definition.MChannel(name=channel, uids=[self.__Config.SERVICE_ID])) self.__Irc.Channel.insert(self.__Irc.Loader.Definition.MChannel(name=channel, uids=[self.__Config.SERVICE_ID]))
return None return None
def sendQuit(self, uid: str, reason: str, print_log: True) -> None: def send_quit(self, uid: str, reason: str, print_log: True) -> None:
"""Send quit message """Send quit message
Args: Args:
@@ -205,7 +205,7 @@ class Inspircd:
return None return None
def sendUID(self, nickname:str, username: str, hostname: str, uid:str, umodes: str, vhost: str, remote_ip: str, realname: str, print_log: bool = True) -> None: def send_uid(self, nickname:str, username: str, hostname: str, uid:str, umodes: str, vhost: str, remote_ip: str, realname: str, print_log: bool = True) -> None:
"""Send UID to the server """Send UID to the server
Args: Args:
@@ -243,7 +243,7 @@ class Inspircd:
except Exception as err: except Exception as err:
self.__Base.logs.error(f"{__name__} - General Error: {err}") self.__Base.logs.error(f"{__name__} - General Error: {err}")
def sendChanJoin(self, uidornickname: str, channel: str, password: str = None, print_log: bool = True) -> None: def send_join_chan(self, uidornickname: str, channel: str, password: str = None, print_log: bool = True) -> None:
"""Joining a channel """Joining a channel
Args: Args:
@@ -269,7 +269,7 @@ class Inspircd:
self.__Irc.Channel.insert(self.__Irc.Loader.Definition.MChannel(name=channel, uids=[userObj.uid])) self.__Irc.Channel.insert(self.__Irc.Loader.Definition.MChannel(name=channel, uids=[userObj.uid]))
return None return None
def sendChanPart(self, uidornickname:str, channel: str, print_log: bool = True) -> None: def send_part_chan(self, uidornickname:str, channel: str, print_log: bool = True) -> None:
"""Part from a channel """Part from a channel
Args: Args:
@@ -633,7 +633,7 @@ class Inspircd:
ping_response = current_unixtime - recieved_unixtime ping_response = current_unixtime - recieved_unixtime
# self.__Irc.send2socket(f':{dnickname} NOTICE {nickname} :\x01PING {ping_response} secs\x01') # self.__Irc.send2socket(f':{dnickname} NOTICE {nickname} :\x01PING {ping_response} secs\x01')
self.sendNotice( self.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=nickname, nick_to=nickname,
msg=f"\x01PING {ping_response} secs\x01" msg=f"\x01PING {ping_response} secs\x01"

View File

@@ -48,7 +48,7 @@ class Unrealircd6:
except AttributeError as ae: except AttributeError as ae:
self.__Base.logs.critical(f"Attribute Error: {ae}") self.__Base.logs.critical(f"Attribute Error: {ae}")
def sendPrivMsg(self, nick_from: str, msg: str, channel: str = None, nick_to: str = None): def send_priv_msg(self, nick_from: str, msg: str, channel: str = None, nick_to: str = None):
"""Sending PRIVMSG to a channel or to a nickname by batches """Sending PRIVMSG to a channel or to a nickname by batches
could be either channel or nickname not both together could be either channel or nickname not both together
Args: Args:
@@ -80,7 +80,7 @@ class Unrealircd6:
self.__Base.logs.error(f"General Error: {err}") self.__Base.logs.error(f"General Error: {err}")
self.__Base.logs.error(f"General Error: {nick_from} - {channel} - {nick_to}") self.__Base.logs.error(f"General Error: {nick_from} - {channel} - {nick_to}")
def sendNotice(self, nick_from: str, nick_to: str, msg: str) -> None: def send_notice(self, nick_from: str, nick_to: str, msg: str) -> None:
"""Sending NOTICE by batches """Sending NOTICE by batches
Args: Args:
@@ -206,7 +206,7 @@ class Unrealircd6:
self.__Irc.Channel.insert(self.__Irc.Loader.Definition.MChannel(name=channel, uids=[self.__Config.SERVICE_ID])) self.__Irc.Channel.insert(self.__Irc.Loader.Definition.MChannel(name=channel, uids=[self.__Config.SERVICE_ID]))
return None return None
def sendSapart(self, nick_to_sapart: str, channel_name: str) -> None: def send_sapart(self, nick_to_sapart: str, channel_name: str) -> None:
"""_summary_ """_summary_
Args: Args:
@@ -231,7 +231,7 @@ class Unrealircd6:
except Exception as err: except Exception as err:
self.__Base.logs.error(f"{__name__} - General Error: {err}") self.__Base.logs.error(f"{__name__} - General Error: {err}")
def sendSajoin(self, nick_to_sajoin: str, channel_name: str) -> None: def send_sajoin(self, nick_to_sajoin: str, channel_name: str) -> None:
"""_summary_ """_summary_
Args: Args:
@@ -268,7 +268,7 @@ class Unrealircd6:
except Exception as err: except Exception as err:
self.__Base.logs.error(f"{__name__} - General Error: {err}") self.__Base.logs.error(f"{__name__} - General Error: {err}")
def sendSvsmode(self, nickname: str, user_mode: str) -> None: def send_svs_mode(self, nickname: str, user_mode: str) -> None:
try: try:
userObj = self.__Irc.User.get_User(uidornickname=nickname) userObj = self.__Irc.User.get_User(uidornickname=nickname)
@@ -287,7 +287,7 @@ class Unrealircd6:
except Exception as err: except Exception as err:
self.__Base.logs.error(f"{__name__} - General Error: {err}") self.__Base.logs.error(f"{__name__} - General Error: {err}")
def sendQuit(self, uid: str, reason: str, print_log: True) -> None: def send_quit(self, uid: str, reason: str, print_log: True) -> None:
"""Send quit message """Send quit message
- Delete uid from User object - Delete uid from User object
- Delete uid from Clone object - Delete uid from Clone object
@@ -316,7 +316,7 @@ class Unrealircd6:
return None return None
def sendUID(self, nickname:str, username: str, hostname: str, uid:str, umodes: str, vhost: str, remote_ip: str, realname: str, print_log: bool = True) -> None: def send_uid(self, nickname:str, username: str, hostname: str, uid:str, umodes: str, vhost: str, remote_ip: str, realname: str, print_log: bool = True) -> None:
"""Send UID to the server """Send UID to the server
- Insert User to User Object - Insert User to User Object
Args: Args:
@@ -354,7 +354,7 @@ class Unrealircd6:
except Exception as err: except Exception as err:
self.__Base.logs.error(f"{__name__} - General Error: {err}") self.__Base.logs.error(f"{__name__} - General Error: {err}")
def sendChanJoin(self, uidornickname: str, channel: str, password: str = None, print_log: bool = True) -> None: def send_join_chan(self, uidornickname: str, channel: str, password: str = None, print_log: bool = True) -> None:
"""Joining a channel """Joining a channel
Args: Args:
@@ -383,7 +383,7 @@ class Unrealircd6:
self.__Irc.Channel.insert(self.__Irc.Loader.Definition.MChannel(name=channel, uids=[userObj.uid])) self.__Irc.Channel.insert(self.__Irc.Loader.Definition.MChannel(name=channel, uids=[userObj.uid]))
return None return None
def sendChanPart(self, uidornickname:str, channel: str, print_log: bool = True) -> None: def send_part_chan(self, uidornickname:str, channel: str, print_log: bool = True) -> None:
"""Part from a channel """Part from a channel
Args: Args:
@@ -742,7 +742,7 @@ class Unrealircd6:
ping_response = current_unixtime - recieved_unixtime ping_response = current_unixtime - recieved_unixtime
# self.__Irc.send2socket(f':{dnickname} NOTICE {nickname} :\x01PING {ping_response} secs\x01') # self.__Irc.send2socket(f':{dnickname} NOTICE {nickname} :\x01PING {ping_response} secs\x01')
self.sendNotice( self.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=nickname, nick_to=nickname,
msg=f"\x01PING {ping_response} secs\x01" msg=f"\x01PING {ping_response} secs\x01"

View File

@@ -408,7 +408,7 @@ class Irc:
self.Logs.info('module name = ' + module_name) self.Logs.info('module name = ' + module_name)
if class_name in self.loaded_classes: if class_name in self.loaded_classes:
# Si le module existe dans la variable globale retourne False # Si le module existe dans la variable globale retourne False
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Le module {module_name} est déja chargé ! si vous souhaiter le recharge tapez {self.Config.SERVICE_PREFIX}reload {module_name}", msg=f"Le module {module_name} est déja chargé ! si vous souhaiter le recharge tapez {self.Config.SERVICE_PREFIX}reload {module_name}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -425,7 +425,7 @@ class Irc:
if not init: if not init:
self.Base.db_record_module(fromuser, module_name) self.Base.db_record_module(fromuser, module_name)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Module {module_name} chargé", msg=f"Module {module_name} chargé",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -439,7 +439,7 @@ class Irc:
create_instance_of_the_class = my_class(self.ircObject) # Créer une nouvelle instance de la classe create_instance_of_the_class = my_class(self.ircObject) # Créer une nouvelle instance de la classe
if not hasattr(create_instance_of_the_class, 'cmd'): if not hasattr(create_instance_of_the_class, 'cmd'):
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Module {module_name} ne contient pas de méthode cmd", msg=f"Module {module_name} ne contient pas de méthode cmd",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -455,7 +455,7 @@ class Irc:
if not init: if not init:
self.Base.db_record_module(fromuser, module_name) self.Base.db_record_module(fromuser, module_name)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Module {module_name} chargé", msg=f"Module {module_name} chargé",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -467,7 +467,7 @@ class Irc:
except ModuleNotFoundError as moduleNotFound: except ModuleNotFoundError as moduleNotFound:
self.Logs.error(f"MODULE_NOT_FOUND: {moduleNotFound}") self.Logs.error(f"MODULE_NOT_FOUND: {moduleNotFound}")
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[ {self.Config.COLORS.red}MODULE_NOT_FOUND{self.Config.COLORS.black} ]: {moduleNotFound}", msg=f"[ {self.Config.COLORS.red}MODULE_NOT_FOUND{self.Config.COLORS.black} ]: {moduleNotFound}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -475,7 +475,7 @@ class Irc:
self.Base.db_delete_module(module_name) self.Base.db_delete_module(module_name)
except Exception as err: except Exception as err:
self.Logs.error(f"Something went wrong with a module you want to load : {err}") self.Logs.error(f"Something went wrong with a module you want to load : {err}")
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[ {self.Config.COLORS.red}ERROR{self.Config.COLORS.black} ]: {err}", msg=f"[ {self.Config.COLORS.red}ERROR{self.Config.COLORS.black} ]: {err}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -508,7 +508,7 @@ class Irc:
# Supprimer le module de la base de données # Supprimer le module de la base de données
self.Base.db_delete_module(module_name) self.Base.db_delete_module(module_name)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Module {module_name} supprimé", msg=f"Module {module_name} supprimé",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -547,14 +547,14 @@ class Irc:
self.loaded_classes[class_name] = new_instance self.loaded_classes[class_name] = new_instance
self.Base.db_update_module(from_user, mod_name) self.Base.db_update_module(from_user, mod_name)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Module {module_name} rechargé", msg=f"Module {module_name} rechargé",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
) )
return False return False
else: else:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Module {module_name} n'est pas chargé !", msg=f"Module {module_name} n'est pas chargé !",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -562,7 +562,7 @@ class Irc:
except TypeError as te: except TypeError as te:
self.Logs.error(f"A TypeError raised: {te}") self.Logs.error(f"A TypeError raised: {te}")
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"A TypeError raised: {te}", msg=f"A TypeError raised: {te}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -570,7 +570,7 @@ class Irc:
self.Base.db_delete_module(module_name) self.Base.db_delete_module(module_name)
except AttributeError as ae: except AttributeError as ae:
self.Logs.error(f"Missing Attribute: {ae}") self.Logs.error(f"Missing Attribute: {ae}")
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Missing Attribute: {ae}", msg=f"Missing Attribute: {ae}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -578,7 +578,7 @@ class Irc:
self.Base.db_delete_module(module_name) self.Base.db_delete_module(module_name)
except KeyError as ke: except KeyError as ke:
self.Logs.error(f"Key Error: {ke}") self.Logs.error(f"Key Error: {ke}")
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Key Error: {ke}", msg=f"Key Error: {ke}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -586,7 +586,7 @@ class Irc:
self.Base.db_delete_module(module_name) self.Base.db_delete_module(module_name)
except Exception as e: except Exception as e:
self.Logs.error(f"Something went wrong with a module you want to reload: {e}") self.Logs.error(f"Something went wrong with a module you want to reload: {e}")
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Something went wrong with the module: {e}", msg=f"Something went wrong with the module: {e}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -621,22 +621,32 @@ class Irc:
return None return None
def create_defender_user(self, nickname:str, level: int, password:str) -> str: def create_defender_user(self, nickname: str, level: int, password: str) -> str:
# > addaccess [nickname] [level] [password]
get_user = self.User.get_User(nickname) get_user = self.User.get_User(nickname)
level = self.Base.convert_to_int(level)
password = password
if get_user is None: if get_user is None:
response = f'This nickname {nickname} does not exist, it is not possible to create this user' response = f'This nickname {nickname} does not exist, it is not possible to create this user'
self.Logs.warning(response) self.Logs.warning(response)
return response return response
nickname = get_user.nickname if level is None:
response = '' response = f'The level [{level}] must be a number from 1 to 4'
self.Logs.warning(response)
return response
if level > 4: if level > 4:
response = "Impossible d'ajouter un niveau > 4" response = "Impossible d'ajouter un niveau > 4"
self.Logs.warning(response) self.Logs.warning(response)
return response return response
nickname = get_user.nickname
response = ''
hostname = get_user.hostname hostname = get_user.hostname
vhost = get_user.vhost vhost = get_user.vhost
spassword = self.Base.crypt_password(password) spassword = self.Base.crypt_password(password)
@@ -654,12 +664,12 @@ class Irc:
(:datetime, :user, :password, :hostname, :vhost, :level) (:datetime, :user, :password, :hostname, :vhost, :level)
''', mes_donnees) ''', mes_donnees)
response = f"{nickname} ajouté en tant qu'administrateur de niveau {level}" response = f"{nickname} ajouté en tant qu'administrateur de niveau {level}"
self.Protocol.sendNotice(nick_from=self.Config.SERVICE_NICKNAME, nick_to=nickname, msg=response) self.Protocol.send_notice(nick_from=self.Config.SERVICE_NICKNAME, nick_to=nickname, msg=response)
self.Logs.info(response) self.Logs.info(response)
return response return response
else: else:
response = f'{nickname} Existe déjà dans les users enregistrés' response = f'{nickname} Existe déjà dans les users enregistrés'
self.Protocol.sendNotice(nick_from=self.Config.SERVICE_NICKNAME, nick_to=nickname, msg=response) self.Protocol.send_notice(nick_from=self.Config.SERVICE_NICKNAME, nick_to=nickname, msg=response)
self.Logs.info(response) self.Logs.info(response)
return response return response
@@ -706,10 +716,10 @@ class Irc:
dnickname = self.Config.SERVICE_NICKNAME dnickname = self.Config.SERVICE_NICKNAME
if self.Base.check_for_new_version(True): if self.Base.check_for_new_version(True):
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" New Version available : {self.Config.CURRENT_VERSION} >>> {self.Config.LATEST_VERSION}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" New Version available : {self.Config.CURRENT_VERSION} >>> {self.Config.LATEST_VERSION}")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=" Please run (git pull origin main) in the current folder") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" Please run (git pull origin main) in the current folder")
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=" You have the latest version of defender") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" You have the latest version of defender")
return None return None
@@ -857,14 +867,14 @@ class Irc:
self.Logs.info(f"################################################") self.Logs.info(f"################################################")
if self.Base.check_for_new_version(False): if self.Base.check_for_new_version(False):
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f" New Version available {version}", msg=f" New Version available {version}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
) )
# Initialisation terminé aprés le premier PING # Initialisation terminé aprés le premier PING
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[{self.Config.COLORS.green}INFORMATION{self.Config.COLORS.nogc}] >> Defender is ready", msg=f"[{self.Config.COLORS.green}INFORMATION{self.Config.COLORS.nogc}] >> Defender is ready",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -954,7 +964,7 @@ class Irc:
arg.remove(f':{self.Config.SERVICE_PREFIX}') arg.remove(f':{self.Config.SERVICE_PREFIX}')
if not arg[0].lower() in self.commands: if not arg[0].lower() in self.commands:
self.Logs.debug(f"This command {arg[0]} is not available") self.Logs.debug(f"This command {arg[0]} is not available")
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
nick_to=user_trigger, nick_to=user_trigger,
msg=f"This command [{self.Config.COLORS.bold}{arg[0]}{self.Config.COLORS.bold}] is not available" msg=f"This command [{self.Config.COLORS.bold}{arg[0]}{self.Config.COLORS.bold}] is not available"
@@ -1061,13 +1071,13 @@ class Irc:
case 'notallowed': case 'notallowed':
try: try:
current_command = cmd[0] current_command = cmd[0]
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
msg=f'[ {self.Config.COLORS.red}{current_command}{self.Config.COLORS.black} ] - Accès Refusé à {self.User.get_nickname(fromuser)}', msg=f'[ {self.Config.COLORS.red}{current_command}{self.Config.COLORS.black} ] - Accès Refusé à {self.User.get_nickname(fromuser)}',
nick_from=dnickname, nick_from=dnickname,
channel=dchanlog channel=dchanlog
) )
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f'Accès Refusé' msg=f'Accès Refusé'
@@ -1082,7 +1092,7 @@ class Irc:
uid_to_deauth = self.User.get_uid(fromuser) uid_to_deauth = self.User.get_uid(fromuser)
self.delete_db_admin(uid_to_deauth) self.delete_db_admin(uid_to_deauth)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
msg=f"[ {self.Config.COLORS.red}{str(current_command).upper()} ]{self.Config.COLORS.black} - {self.User.get_nickname(fromuser)} est désormais déconnecter de {dnickname}", msg=f"[ {self.Config.COLORS.red}{str(current_command).upper()} ]{self.Config.COLORS.black} - {self.User.get_nickname(fromuser)} est désormais déconnecter de {dnickname}",
nick_from=dnickname, nick_from=dnickname,
channel=dchanlog channel=dchanlog
@@ -1099,7 +1109,7 @@ class Irc:
result_db = result.fetchone() result_db = result.fetchone()
if result_db[0] > 0: if result_db[0] > 0:
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"You can't use this command anymore ! Please use [{self.Config.SERVICE_PREFIX}auth] instead" msg=f"You can't use this command anymore ! Please use [{self.Config.SERVICE_PREFIX}auth] instead"
@@ -1120,7 +1130,7 @@ class Irc:
if current_nickname != cmd_owner: if current_nickname != cmd_owner:
self.Logs.critical(f"The current nickname [{fromuser}] is different than the nickname sent [{cmd_owner}] !") self.Logs.critical(f"The current nickname [{fromuser}] is different than the nickname sent [{cmd_owner}] !")
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"The current nickname [{fromuser}] is different than the nickname sent [{cmd_owner}] !" msg=f"The current nickname [{fromuser}] is different than the nickname sent [{cmd_owner}] !"
@@ -1129,7 +1139,7 @@ class Irc:
if current_nickname != config_owner: if current_nickname != config_owner:
self.Logs.critical(f"The current nickname [{current_nickname}] is different than the configuration owner [{config_owner}] !") self.Logs.critical(f"The current nickname [{current_nickname}] is different than the configuration owner [{config_owner}] !")
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"The current nickname [{current_nickname}] is different than the configuration owner [{config_owner}] !" msg=f"The current nickname [{current_nickname}] is different than the configuration owner [{config_owner}] !"
@@ -1138,7 +1148,7 @@ class Irc:
if cmd_owner != config_owner: if cmd_owner != config_owner:
self.Logs.critical(f"The nickname sent [{cmd_owner}] is different than the configuration owner [{config_owner}] !") self.Logs.critical(f"The nickname sent [{cmd_owner}] is different than the configuration owner [{config_owner}] !")
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"The nickname sent [{cmd_owner}] is different than the configuration owner [{config_owner}] !" msg=f"The nickname sent [{cmd_owner}] is different than the configuration owner [{config_owner}] !"
@@ -1148,25 +1158,25 @@ class Irc:
if cmd_owner == config_owner and cmd_password == config_password: if cmd_owner == config_owner and cmd_password == config_password:
self.Base.db_create_first_admin() self.Base.db_create_first_admin()
self.insert_db_admin(current_uid, 5) self.insert_db_admin(current_uid, 5)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
msg=f"[ {self.Config.COLORS.green}{str(current_command).upper()} ]{self.Config.COLORS.black} - {self.User.get_nickname(fromuser)} est désormais connecté a {dnickname}", msg=f"[ {self.Config.COLORS.green}{str(current_command).upper()} ]{self.Config.COLORS.black} - {self.User.get_nickname(fromuser)} est désormais connecté a {dnickname}",
nick_from=dnickname, nick_from=dnickname,
channel=dchanlog channel=dchanlog
) )
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"Connexion a {dnickname} réussie!" msg=f"Connexion a {dnickname} réussie!"
) )
else: else:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
msg=f"[ {self.Config.COLORS.red}{str(current_command).upper()} ]{self.Config.COLORS.black} - {self.User.get_nickname(fromuser)} a tapé un mauvais mot de pass", msg=f"[ {self.Config.COLORS.red}{str(current_command).upper()} ]{self.Config.COLORS.black} - {self.User.get_nickname(fromuser)} a tapé un mauvais mot de pass",
nick_from=dnickname, nick_from=dnickname,
channel=dchanlog channel=dchanlog
) )
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"Mot de passe incorrecte" msg=f"Mot de passe incorrecte"
@@ -1180,7 +1190,7 @@ class Irc:
if fromuser != user_to_log: if fromuser != user_to_log:
# If the current nickname is different from the nickname you want to log in with # If the current nickname is different from the nickname you want to log in with
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Your current nickname is different from the nickname you want to log in with") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Your current nickname is different from the nickname you want to log in with")
return False return False
if not user_to_log is None: if not user_to_log is None:
@@ -1192,25 +1202,25 @@ class Irc:
if not user_from_db is None: if not user_from_db is None:
uid_user = self.User.get_uid(user_to_log) uid_user = self.User.get_uid(user_to_log)
self.insert_db_admin(uid_user, user_from_db[1]) self.insert_db_admin(uid_user, user_from_db[1])
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}{str(current_command).upper()} ]{self.Config.COLORS.nogc} - {self.User.get_nickname(fromuser)} est désormais connecté a {dnickname}", msg=f"[ {self.Config.COLORS.green}{str(current_command).upper()} ]{self.Config.COLORS.nogc} - {self.User.get_nickname(fromuser)} est désormais connecté a {dnickname}",
channel=dchanlog) channel=dchanlog)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Connexion a {dnickname} réussie!") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Connexion a {dnickname} réussie!")
else: else:
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"[ {self.Config.COLORS.red}{str(current_command).upper()} ]{self.Config.COLORS.nogc} - {self.User.get_nickname(fromuser)} a tapé un mauvais mot de pass", msg=f"[ {self.Config.COLORS.red}{str(current_command).upper()} ]{self.Config.COLORS.nogc} - {self.User.get_nickname(fromuser)} a tapé un mauvais mot de pass",
channel=dchanlog) channel=dchanlog)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Mot de passe incorrecte") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Mot de passe incorrecte")
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"L'utilisateur {user_to_log} n'existe pas") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"L'utilisateur {user_to_log} n'existe pas")
case 'addaccess': case 'addaccess':
try: try:
# .addaccess adator 5 password # .addaccess adator 5 password
if len(cmd) < 4: if len(cmd) < 4:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Right command : /msg {dnickname} addaccess [nickname] [level] [password]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Right command : /msg {dnickname} addaccess [nickname] [level] [password]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"level: from 1 to 4") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"level: from 1 to 4")
newnickname = cmd[1] newnickname = cmd[1]
newlevel = self.Base.int_if_possible(cmd[2]) newlevel = self.Base.int_if_possible(cmd[2])
@@ -1218,15 +1228,15 @@ class Irc:
response = self.create_defender_user(newnickname, newlevel, password) response = self.create_defender_user(newnickname, newlevel, password)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"{response}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"{response}")
self.Logs.info(response) self.Logs.info(response)
except IndexError as ie: except IndexError as ie:
self.Logs.error(f'_hcmd addaccess: {ie}') self.Logs.error(f'_hcmd addaccess: {ie}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} addaccess [nickname] [level] [password]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} addaccess [nickname] [level] [password]")
except TypeError as te: except TypeError as te:
self.Logs.error(f'_hcmd addaccess: out of index : {te}') self.Logs.error(f'_hcmd addaccess: out of index : {te}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} addaccess [nickname] [level] [password]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} addaccess [nickname] [level] [password]")
case 'editaccess': case 'editaccess':
# .editaccess [USER] [PASSWORD] [LEVEL] # .editaccess [USER] [PASSWORD] [LEVEL]
@@ -1236,12 +1246,12 @@ class Irc:
user_password = self.Base.crypt_password(cmd[2]) user_password = self.Base.crypt_password(cmd[2])
if len(cmd) < 4 or len(cmd) > 4: if len(cmd) < 4 or len(cmd) > 4:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"{self.Config.SERVICE_PREFIX}editaccess [USER] [NEWPASSWORD] [NEWLEVEL]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"{self.Config.SERVICE_PREFIX}editaccess [USER] [NEWPASSWORD] [NEWLEVEL]")
return None return None
get_admin = self.Admin.get_Admin(fromuser) get_admin = self.Admin.get_Admin(fromuser)
if get_admin is None: if get_admin is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" This user {fromuser} has no Admin access") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" This user {fromuser} has no Admin access")
return None return None
current_user = self.User.get_nickname(fromuser) current_user = self.User.get_nickname(fromuser)
@@ -1249,7 +1259,7 @@ class Irc:
current_user_level = get_admin.level current_user_level = get_admin.level
if user_new_level > 5: if user_new_level > 5:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Maximum authorized level is 5") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Maximum authorized level is 5")
return None return None
# Rechercher le user dans la base de données. # Rechercher le user dans la base de données.
@@ -1261,11 +1271,11 @@ class Irc:
if not isUserExist is None: if not isUserExist is None:
if current_user_level < int(isUserExist[1]): if current_user_level < int(isUserExist[1]):
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" You are not allowed to edit this access") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" You are not allowed to edit this access")
return None return None
if current_user_level == int(isUserExist[1]) and current_user != user_to_edit: if current_user_level == int(isUserExist[1]) and current_user != user_to_edit:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" You can't edit access of a user with same level") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" You can't edit access of a user with same level")
return None return None
# Le user existe dans la base de données # Le user existe dans la base de données
@@ -1273,16 +1283,16 @@ class Irc:
sql_update = f"UPDATE {self.Config.TABLE_ADMIN} SET level = :level, password = :password WHERE user = :user" sql_update = f"UPDATE {self.Config.TABLE_ADMIN} SET level = :level, password = :password WHERE user = :user"
exec_query = self.Base.db_execute_query(sql_update, data_to_update) exec_query = self.Base.db_execute_query(sql_update, data_to_update)
if exec_query.rowcount > 0: if exec_query.rowcount > 0:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" User {user_to_edit} has been modified with level {str(user_new_level)}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" User {user_to_edit} has been modified with level {str(user_new_level)}")
self.Admin.update_level(user_to_edit, user_new_level) self.Admin.update_level(user_to_edit, user_new_level)
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Impossible de modifier l'utilisateur {str(user_new_level)}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Impossible de modifier l'utilisateur {str(user_new_level)}")
except TypeError as te: except TypeError as te:
self.Logs.error(f"Type error : {te}") self.Logs.error(f"Type error : {te}")
except ValueError as ve: except ValueError as ve:
self.Logs.error(f"Value Error : {ve}") self.Logs.error(f"Value Error : {ve}")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" {self.Config.SERVICE_PREFIX}editaccess [USER] [NEWPASSWORD] [NEWLEVEL]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" {self.Config.SERVICE_PREFIX}editaccess [USER] [NEWPASSWORD] [NEWLEVEL]")
case 'delaccess': case 'delaccess':
# .delaccess [USER] [CONFIRMUSER] # .delaccess [USER] [CONFIRMUSER]
@@ -1290,18 +1300,18 @@ class Irc:
user_confirmation = cmd[2] user_confirmation = cmd[2]
if user_to_del != user_confirmation: if user_to_del != user_confirmation:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Les user ne sont pas les mêmes, tu dois confirmer le user que tu veux supprimer") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Les user ne sont pas les mêmes, tu dois confirmer le user que tu veux supprimer")
self.Logs.warning(f':{dnickname} NOTICE {fromuser} : Les user ne sont pas les mêmes, tu dois confirmer le user que tu veux supprimer') self.Logs.warning(f':{dnickname} NOTICE {fromuser} : Les user ne sont pas les mêmes, tu dois confirmer le user que tu veux supprimer')
return None return None
if len(cmd) < 3: if len(cmd) < 3:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"{self.Config.SERVICE_PREFIX}delaccess [USER] [CONFIRMUSER]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"{self.Config.SERVICE_PREFIX}delaccess [USER] [CONFIRMUSER]")
return None return None
get_admin = self.Admin.get_Admin(fromuser) get_admin = self.Admin.get_Admin(fromuser)
if get_admin is None: if get_admin is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"This user {fromuser} has no admin access") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"This user {fromuser} has no admin access")
return None return None
current_user = self.User.get_nickname(fromuser) current_user = self.User.get_nickname(fromuser)
@@ -1317,7 +1327,7 @@ class Irc:
if not info_user is None: if not info_user is None:
level_user_to_del = info_user[1] level_user_to_del = info_user[1]
if current_user_level <= level_user_to_del: if current_user_level <= level_user_to_del:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"You are not allowed to delete this access") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"You are not allowed to delete this access")
self.Logs.warning(f':{dnickname} NOTICE {fromuser} : You are not allowed to delete this access') self.Logs.warning(f':{dnickname} NOTICE {fromuser} : You are not allowed to delete this access')
return None return None
@@ -1325,10 +1335,10 @@ class Irc:
sql_delete = f"DELETE FROM {self.Config.TABLE_ADMIN} WHERE user = :user" sql_delete = f"DELETE FROM {self.Config.TABLE_ADMIN} WHERE user = :user"
exec_query = self.Base.db_execute_query(sql_delete, data_to_delete) exec_query = self.Base.db_execute_query(sql_delete, data_to_delete)
if exec_query.rowcount > 0: if exec_query.rowcount > 0:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"User {user_to_del} has been deleted !") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"User {user_to_del} has been deleted !")
self.Admin.delete(user_to_del) self.Admin.delete(user_to_del)
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Impossible de supprimer l'utilisateur.") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Impossible de supprimer l'utilisateur.")
self.Logs.warning(f":{dnickname} NOTICE {fromuser} : Impossible de supprimer l'utilisateur.") self.Logs.warning(f":{dnickname} NOTICE {fromuser} : Impossible de supprimer l'utilisateur.")
case 'help': case 'help':
@@ -1340,13 +1350,13 @@ class Irc:
else: else:
user_level = 0 user_level = 0
self.Protocol.sendNotice(nick_from=dnickname,nick_to=fromuser,msg=f" ***************** LISTE DES COMMANDES *****************") self.Protocol.send_notice(nick_from=dnickname,nick_to=fromuser,msg=f" ***************** LISTE DES COMMANDES *****************")
self.Protocol.sendNotice(nick_from=dnickname,nick_to=fromuser,msg=f" ") self.Protocol.send_notice(nick_from=dnickname,nick_to=fromuser,msg=f" ")
for levDef in self.commands_level: for levDef in self.commands_level:
if int(user_level) >= int(count_level_definition): if int(user_level) >= int(count_level_definition):
self.Protocol.sendNotice(nick_from=dnickname,nick_to=fromuser, self.Protocol.send_notice(nick_from=dnickname,nick_to=fromuser,
msg=f" ***************** {self.Config.COLORS.nogc}[ {self.Config.COLORS.green}LEVEL {str(levDef)} {self.Config.COLORS.nogc}] *****************" msg=f" ***************** {self.Config.COLORS.nogc}[ {self.Config.COLORS.green}LEVEL {str(levDef)} {self.Config.COLORS.nogc}] *****************"
) )
@@ -1354,13 +1364,13 @@ class Irc:
for i in range(0, len(self.commands_level[count_level_definition]), batch): for i in range(0, len(self.commands_level[count_level_definition]), batch):
groupe = self.commands_level[count_level_definition][i:i + batch] # Extraire le groupe groupe = self.commands_level[count_level_definition][i:i + batch] # Extraire le groupe
batch_commands = ' | '.join(groupe) batch_commands = ' | '.join(groupe)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" {batch_commands}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" {batch_commands}")
self.Protocol.sendNotice(nick_from=dnickname,nick_to=fromuser,msg=f" ") self.Protocol.send_notice(nick_from=dnickname,nick_to=fromuser,msg=f" ")
count_level_definition += 1 count_level_definition += 1
self.Protocol.sendNotice(nick_from=dnickname,nick_to=fromuser,msg=f" ***************** FIN DES COMMANDES *****************") self.Protocol.send_notice(nick_from=dnickname,nick_to=fromuser,msg=f" ***************** FIN DES COMMANDES *****************")
case 'load': case 'load':
try: try:
@@ -1387,7 +1397,7 @@ class Irc:
self.reload_module(from_user=fromuser, mod_name=module_name) self.reload_module(from_user=fromuser, mod_name=module_name)
except Exception as e: except Exception as e:
self.Logs.error(f"Something went wrong with a module you want to reload: {e}") self.Logs.error(f"Something went wrong with a module you want to reload: {e}")
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"Something went wrong with the module: {e}", msg=f"Something went wrong with the module: {e}",
channel=dchanlog channel=dchanlog
@@ -1403,7 +1413,7 @@ class Irc:
self.Base.shutdown() self.Base.shutdown()
self.Base.execute_periodic_action() self.Base.execute_periodic_action()
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"Arrêt du service {dnickname}" msg=f"Arrêt du service {dnickname}"
@@ -1422,7 +1432,7 @@ class Irc:
reason.append(cmd[i]) reason.append(cmd[i])
final_reason = ' '.join(reason) final_reason = ' '.join(reason)
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"Redémarrage du service {dnickname}" msg=f"Redémarrage du service {dnickname}"
@@ -1476,7 +1486,7 @@ class Irc:
for key, value in conf_bkp_dict.items(): for key, value in conf_bkp_dict.items():
if config_dict[key] != value: if config_dict[key] != value:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f'[{key}]: {value} ==> {config_dict[key]}', msg=f'[{key}]: {value} ==> {config_dict[key]}',
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -1489,7 +1499,7 @@ class Irc:
if restart_flag: if restart_flag:
self.Config.SERVEUR_ID = serveur_id self.Config.SERVEUR_ID = serveur_id
self.Protocol.sendPrivMsg(nick_from=self.Config.SERVICE_NICKNAME, msg='You need to restart defender !', channel=self.Config.SERVICE_CHANLOG) self.Protocol.send_priv_msg(nick_from=self.Config.SERVICE_NICKNAME, msg='You need to restart defender !', channel=self.Config.SERVICE_CHANLOG)
self.Base.delete_logger(self.Config.LOGGING_NAME) self.Base.delete_logger(self.Config.LOGGING_NAME)
self.Base = self.Loader.BaseModule.Base(self.Config, self.Settings) self.Base = self.Loader.BaseModule.Base(self.Config, self.Settings)
@@ -1500,7 +1510,7 @@ class Irc:
self.Protocol = Protocol(self.Config.SERVEUR_PROTOCOL, self.ircObject).Protocol self.Protocol = Protocol(self.Config.SERVEUR_PROTOCOL, self.ircObject).Protocol
for mod in mods: for mod in mods:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f'> Module [{mod}] reloaded', msg=f'> Module [{mod}] reloaded',
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -1525,14 +1535,14 @@ class Irc:
loaded = True loaded = True
if loaded: if loaded:
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"{module} - {self.Config.COLORS.green}Loaded{self.Config.COLORS.nogc} by {loaded_user} on {loaded_datetime}" msg=f"{module} - {self.Config.COLORS.green}Loaded{self.Config.COLORS.nogc} by {loaded_user} on {loaded_datetime}"
) )
loaded = False loaded = False
else: else:
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"{module} - {self.Config.COLORS.red}Not Loaded{self.Config.COLORS.nogc}" msg=f"{module} - {self.Config.COLORS.red}Not Loaded{self.Config.COLORS.nogc}"
@@ -1542,13 +1552,13 @@ class Irc:
if self.Base.running_timers: if self.Base.running_timers:
for the_timer in self.Base.running_timers: for the_timer in self.Base.running_timers:
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f">> {the_timer.getName()} - {the_timer.is_alive()}" msg=f">> {the_timer.getName()} - {the_timer.is_alive()}"
) )
else: else:
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg="Aucun timers en cours d'execution" msg="Aucun timers en cours d'execution"
@@ -1557,7 +1567,7 @@ class Irc:
case 'show_threads': case 'show_threads':
for thread in self.Base.running_threads: for thread in self.Base.running_threads:
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f">> {thread.getName()} ({thread.is_alive()})" msg=f">> {thread.getName()} ({thread.is_alive()})"
@@ -1572,7 +1582,7 @@ class Irc:
parsed_UID = re.sub(pattern, '', uid) parsed_UID = re.sub(pattern, '', uid)
list_nicknames.append(self.User.get_nickname(parsed_UID)) list_nicknames.append(self.User.get_nickname(parsed_UID))
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"Channel: {chan.name} - Users: {list_nicknames}" msg=f"Channel: {chan.name} - Users: {list_nicknames}"
@@ -1580,9 +1590,9 @@ class Irc:
case 'show_users': case 'show_users':
count_users = len(self.User.UID_DB) count_users = len(self.User.UID_DB)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Total Connected Users: {count_users}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Total Connected Users: {count_users}")
for db_user in self.User.UID_DB: for db_user in self.User.UID_DB:
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"UID : {db_user.uid} - isWebirc: {db_user.isWebirc} - isWebSocket: {db_user.isWebsocket} - Nickname: {db_user.nickname} - Connection: {db_user.connexion_datetime}" msg=f"UID : {db_user.uid} - isWebirc: {db_user.isWebirc} - isWebSocket: {db_user.isWebsocket} - Nickname: {db_user.nickname} - Connection: {db_user.connexion_datetime}"
@@ -1591,7 +1601,7 @@ class Irc:
case 'show_admins': case 'show_admins':
for db_admin in self.Admin.UID_ADMIN_DB: for db_admin in self.Admin.UID_ADMIN_DB:
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"UID : {db_admin.uid} - Nickname: {db_admin.nickname} - Level: {db_admin.level} - Connection: {db_admin.connexion_datetime}" msg=f"UID : {db_admin.uid} - Nickname: {db_admin.nickname} - Level: {db_admin.level} - Connection: {db_admin.connexion_datetime}"
@@ -1602,7 +1612,7 @@ class Irc:
config_dict = self.Config.__dict__ config_dict = self.Config.__dict__
for key, value in config_dict.items(): for key, value in config_dict.items():
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f'{key} > {value}' msg=f'{key} > {value}'
@@ -1610,14 +1620,14 @@ class Irc:
case 'uptime': case 'uptime':
uptime = self.get_defender_uptime() uptime = self.get_defender_uptime()
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"{uptime}" msg=f"{uptime}"
) )
case 'copyright': case 'copyright':
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"# Defender V.{self.Config.CURRENT_VERSION} Developped by adator® #" msg=f"# Defender V.{self.Config.CURRENT_VERSION} Developped by adator® #"

View File

@@ -1,4 +1,5 @@
from core.classes import user, admin, channel, clone, reputation, settings from core.classes import user, admin, channel, clone, reputation, settings
import utils
import core.definition as df import core.definition as df
import core.base as baseModule import core.base as baseModule
import core.classes.config as confModule import core.classes.config as confModule
@@ -14,6 +15,8 @@ class Loader:
self.BaseModule: baseModule = baseModule self.BaseModule: baseModule = baseModule
self.Utils: utils
# Load Classes # Load Classes
self.Settings: settings = settings.Settings() self.Settings: settings = settings.Settings()

74
core/utils.py Normal file
View File

@@ -0,0 +1,74 @@
from typing import Literal, Union
from datetime import datetime
from time import time
from random import choice
from hashlib import md5, sha3_512
def convert_to_int(value: any) -> Union[int, None]:
"""Convert a value to int
Args:
value (any): Value to convert to int if possible
Returns:
Union[int, None]: Return the int value or None if not possible
"""
try:
value_to_int = int(value)
return value_to_int
except ValueError:
return None
except Exception:
return None
def get_unixtime() -> int:
"""Cette fonction retourne un UNIXTIME de type 12365456
Returns:
int: Current time in seconds since the Epoch (int)
"""
return int(time())
def get_datetime() -> str:
"""Retourne une date au format string (24-12-2023 20:50:59)
Returns:
str: Current datetime in this format %d-%m-%Y %H:%M:%S
"""
currentdate = datetime.now().strftime('%d-%m-%Y %H:%M:%S')
return currentdate
def generate_random_string(lenght: int) -> str:
"""Retourn une chaîne aléatoire en fonction de la longueur spécifiée.
Returns:
str: The random string
"""
caracteres = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
randomize = ''.join(choice(caracteres) for _ in range(lenght))
return randomize
def hash(password: str, algorithm: Literal["md5, sha3_512"] = 'md5') -> str:
"""Retourne un mot de passe chiffré en fonction de l'algorithme utilisé
Args:
password (str): Le password en clair
algorithm (str): L'algorithm a utilisé
Returns:
str: Le password haché
"""
match algorithm:
case 'md5':
password = md5(password.encode()).hexdigest()
return password
case 'sha3_512':
password = sha3_512(password.encode()).hexdigest()
return password
case _:
password = md5(password.encode()).hexdigest()
return password

View File

@@ -73,7 +73,7 @@ class Clone():
self.__load_module_configuration() self.__load_module_configuration()
self.Channel.db_query_channel(action='add', module_name=self.module_name, channel_name=self.Config.CLONE_CHANNEL) self.Channel.db_query_channel(action='add', module_name=self.module_name, channel_name=self.Config.CLONE_CHANNEL)
self.Protocol.sendChanJoin(self.Config.SERVICE_NICKNAME, self.Config.CLONE_CHANNEL) self.Protocol.send_join_chan(self.Config.SERVICE_NICKNAME, self.Config.CLONE_CHANNEL)
self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} SAMODE {self.Config.CLONE_CHANNEL} +o {self.Config.SERVICE_NICKNAME}") self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} SAMODE {self.Config.CLONE_CHANNEL} +o {self.Config.SERVICE_NICKNAME}")
self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} MODE {self.Config.CLONE_CHANNEL} +nts") self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} MODE {self.Config.CLONE_CHANNEL} +nts")
@@ -140,7 +140,7 @@ class Clone():
self.Channel.db_query_channel(action='del', module_name=self.module_name, channel_name=self.Config.CLONE_CHANNEL) self.Channel.db_query_channel(action='del', module_name=self.module_name, channel_name=self.Config.CLONE_CHANNEL)
self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} MODE {self.Config.CLONE_CHANNEL} -nts") self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} MODE {self.Config.CLONE_CHANNEL} -nts")
self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} MODE {self.Config.CLONE_CHANNEL} -k {self.Config.CLONE_CHANNEL_PASSWORD}") self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} MODE {self.Config.CLONE_CHANNEL} -k {self.Config.CLONE_CHANNEL_PASSWORD}")
self.Protocol.sendChanPart(self.Config.SERVICE_NICKNAME, self.Config.CLONE_CHANNEL) self.Protocol.send_part_chan(self.Config.SERVICE_NICKNAME, self.Config.CLONE_CHANNEL)
return None return None
@@ -244,8 +244,8 @@ class Clone():
break break
if not clone.connected: if not clone.connected:
self.Protocol.sendUID(clone.nickname, clone.username, clone.hostname, clone.uid, clone.umodes, clone.vhost, clone.remote_ip, clone.realname, print_log=False) self.Protocol.send_uid(clone.nickname, clone.username, clone.hostname, clone.uid, clone.umodes, clone.vhost, clone.remote_ip, clone.realname, print_log=False)
self.Protocol.sendChanJoin(uidornickname=clone.uid, channel=self.Config.CLONE_CHANNEL, password=self.Config.CLONE_CHANNEL_PASSWORD, print_log=False) self.Protocol.send_join_chan(uidornickname=clone.uid, channel=self.Config.CLONE_CHANNEL, password=self.Config.CLONE_CHANNEL_PASSWORD, print_log=False)
time.sleep(interval) time.sleep(interval)
clone.connected = True clone.connected = True
@@ -257,7 +257,7 @@ class Clone():
clone_to_kill.append(clone.uid) clone_to_kill.append(clone.uid)
for clone_uid in clone_to_kill: for clone_uid in clone_to_kill:
self.Protocol.sendQuit(clone_uid, 'Gooood bye', print_log=False) self.Protocol.send_quit(clone_uid, 'Gooood bye', print_log=False)
del clone_to_kill del clone_to_kill
@@ -297,7 +297,7 @@ class Clone():
if getClone.uid != self.Config.SERVICE_ID: if getClone.uid != self.Config.SERVICE_ID:
final_message = f"{senderObj.nickname}!{senderObj.username}@{senderObj.hostname} > {senderMsg.lstrip(':')}" final_message = f"{senderObj.nickname}!{senderObj.username}@{senderObj.hostname} > {senderMsg.lstrip(':')}"
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=getClone.uid, nick_from=getClone.uid,
msg=final_message, msg=final_message,
channel=self.Config.CLONE_CHANNEL channel=self.Config.CLONE_CHANNEL
@@ -319,11 +319,11 @@ class Clone():
case 'clone': case 'clone':
if len(cmd) == 1: if len(cmd) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone connect NUMBER GROUP_NAME INTERVAL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone connect NUMBER GROUP_NAME INTERVAL")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone kill [all | nickname]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone kill [all | nickname]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone join [all | nickname] #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone join [all | nickname] #channel")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone part [all | nickname] #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone part [all | nickname] #channel")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone list") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone list")
option = str(cmd[1]).lower() option = str(cmd[1]).lower()
@@ -344,8 +344,8 @@ class Clone():
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone connect [number of clone you want to connect] [Group]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone connect [number of clone you want to connect] [Group]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Exemple /msg {dnickname} clone connect 6 Ambiance") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Exemple /msg {dnickname} clone connect 6 Ambiance")
case 'kill': case 'kill':
try: try:
@@ -360,12 +360,12 @@ class Clone():
else: else:
cloneObj = self.Clone.get_Clone(clone_name) cloneObj = self.Clone.get_Clone(clone_name)
if not cloneObj is None: if not cloneObj is None:
self.Protocol.sendQuit(cloneObj.uid, 'Goood bye', print_log=False) self.Protocol.send_quit(cloneObj.uid, 'Goood bye', print_log=False)
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone kill all") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone kill all")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone kill clone_nickname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone kill clone_nickname")
case 'join': case 'join':
try: try:
@@ -376,17 +376,17 @@ class Clone():
if clone_name.lower() == 'all': if clone_name.lower() == 'all':
for clone in self.Clone.UID_CLONE_DB: for clone in self.Clone.UID_CLONE_DB:
self.Protocol.sendChanJoin(uidornickname=clone.uid, channel=clone_channel_to_join, print_log=False) self.Protocol.send_join_chan(uidornickname=clone.uid, channel=clone_channel_to_join, print_log=False)
else: else:
if self.Clone.exists(clone_name): if self.Clone.exists(clone_name):
if not self.Clone.get_uid(clone_name) is None: if not self.Clone.get_uid(clone_name) is None:
self.Protocol.sendChanJoin(uidornickname=clone_name, channel=clone_channel_to_join, print_log=False) self.Protocol.send_join_chan(uidornickname=clone_name, channel=clone_channel_to_join, print_log=False)
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone join all #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone join all #channel")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone join clone_nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone join clone_nickname #channel")
case 'part': case 'part':
try: try:
@@ -397,25 +397,25 @@ class Clone():
if clone_name.lower() == 'all': if clone_name.lower() == 'all':
for clone in self.Clone.UID_CLONE_DB: for clone in self.Clone.UID_CLONE_DB:
self.Protocol.sendChanPart(uidornickname=clone.uid, channel=clone_channel_to_part, print_log=False) self.Protocol.send_part_chan(uidornickname=clone.uid, channel=clone_channel_to_part, print_log=False)
else: else:
if self.Clone.exists(clone_name): if self.Clone.exists(clone_name):
clone_uid = self.Clone.get_uid(clone_name) clone_uid = self.Clone.get_uid(clone_name)
if not clone_uid is None: if not clone_uid is None:
self.Protocol.sendChanPart(uidornickname=clone_uid, channel=clone_channel_to_part, print_log=False) self.Protocol.send_part_chan(uidornickname=clone_uid, channel=clone_channel_to_part, print_log=False)
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone part all #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone part all #channel")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone part clone_nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone part clone_nickname #channel")
case 'list': case 'list':
try: try:
clone_count = len(self.Clone.UID_CLONE_DB) clone_count = len(self.Clone.UID_CLONE_DB)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f">> Number of connected clones: {clone_count}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f">> Number of connected clones: {clone_count}")
for clone_name in self.Clone.UID_CLONE_DB: for clone_name in self.Clone.UID_CLONE_DB:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,
msg=f">> Nickname: {clone_name.nickname} | Username: {clone_name.username} | Realname: {clone_name.realname} | Vhost: {clone_name.vhost} | UID: {clone_name.uid} | Group: {clone_name.group} | Connected: {clone_name.connected}") msg=f">> Nickname: {clone_name.nickname} | Username: {clone_name.username} | Realname: {clone_name.realname} | Vhost: {clone_name.vhost} | UID: {clone_name.uid} | Group: {clone_name.group} | Connected: {clone_name.connected}")
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
@@ -429,7 +429,7 @@ class Clone():
final_message = ' '.join(cmd[4:]) final_message = ' '.join(cmd[4:])
if clone_channel is None or not self.Clone.exists(clone_name): if clone_channel is None or not self.Clone.exists(clone_name):
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"/msg {dnickname} clone say [clone_nickname] #channel message" msg=f"/msg {dnickname} clone say [clone_nickname] #channel message"
@@ -437,22 +437,22 @@ class Clone():
return None return None
if self.Clone.exists(clone_name): if self.Clone.exists(clone_name):
self.Protocol.sendPrivMsg(nick_from=clone_name, msg=final_message, channel=clone_channel) self.Protocol.send_priv_msg(nick_from=clone_name, msg=final_message, channel=clone_channel)
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f"/msg {dnickname} clone say [clone_nickname] #channel message" msg=f"/msg {dnickname} clone say [clone_nickname] #channel message"
) )
case _: case _:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone connect NUMBER GROUP_NAME INTERVAL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone connect NUMBER GROUP_NAME INTERVAL")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone kill [all | nickname]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone kill [all | nickname]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone join [all | nickname] #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone join [all | nickname] #channel")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone part [all | nickname] #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone part [all | nickname] #channel")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone list") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} clone list")
except IndexError as ie: except IndexError as ie:
self.Logs.error(f'Index Error: {ie}') self.Logs.error(f'Index Error: {ie}')

View File

@@ -155,7 +155,7 @@ class Command():
case '403' | '401': case '403' | '401':
try: try:
message = ' '.join(cmd[3:]) message = ' '.join(cmd[3:])
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=self.user_to_notice, nick_to=self.user_to_notice,
msg=f"[{red}ERROR MSG{nogc}] {message}" msg=f"[{red}ERROR MSG{nogc}] {message}"
@@ -171,7 +171,7 @@ class Command():
# [':irc.deb.biz.st', '006', 'Dev-PyDefender', ':`-services.deb.biz.st', '------', '|', 'Users:', '9', '(47.37%)', '[00B]'] # [':irc.deb.biz.st', '006', 'Dev-PyDefender', ':`-services.deb.biz.st', '------', '|', 'Users:', '9', '(47.37%)', '[00B]']
# [':irc.deb.biz.st', '018', 'Dev-PyDefender', ':4', 'servers', 'and', '19', 'users,', 'average', '4.75', 'users', 'per', 'server'] # [':irc.deb.biz.st', '018', 'Dev-PyDefender', ':4', 'servers', 'and', '19', 'users,', 'average', '4.75', 'users', 'per', 'server']
message = ' '.join(cmd[3:]) message = ' '.join(cmd[3:])
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=dnickname, nick_from=dnickname,
nick_to=self.user_to_notice, nick_to=self.user_to_notice,
msg=f"[{green}SERVER MSG{nogc}] {message}" msg=f"[{green}SERVER MSG{nogc}] {message}"
@@ -193,11 +193,11 @@ class Command():
match type_of_stats: match type_of_stats:
case 's': case 's':
self.Protocol.sendNotice(nick_from=dnickname,nick_to=self.user_to_notice, msg="No shun") self.Protocol.send_notice(nick_from=dnickname,nick_to=self.user_to_notice, msg="No shun")
case 'G': case 'G':
self.Protocol.sendNotice(nick_from=dnickname,nick_to=self.user_to_notice, msg="No gline") self.Protocol.send_notice(nick_from=dnickname,nick_to=self.user_to_notice, msg="No gline")
case 'k': case 'k':
self.Protocol.sendNotice(nick_from=dnickname,nick_to=self.user_to_notice, msg="No kline") self.Protocol.send_notice(nick_from=dnickname,nick_to=self.user_to_notice, msg="No kline")
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
@@ -212,7 +212,7 @@ class Command():
author = str(cmd[7]) author = str(cmd[7])
reason = ' '.join(cmd[8:]) reason = ' '.join(cmd[8:])
self.Protocol.sendNotice(nick_from=dnickname,nick_to=self.user_to_notice, self.Protocol.send_notice(nick_from=dnickname,nick_to=self.user_to_notice,
msg=f"{bold}Author{nogc}: {author} - {bold}Host{nogc}: {host} - {bold}Reason{nogc}: {reason}" msg=f"{bold}Author{nogc}: {author} - {bold}Host{nogc}: {host} - {bold}Reason{nogc}: {reason}"
) )
@@ -307,7 +307,7 @@ class Command():
# [':adator', 'PRIVMSG', '#services', ':.o', '#services', 'dktmb'] # [':adator', 'PRIVMSG', '#services', ':.o', '#services', 'dktmb']
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} op [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} op [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -325,7 +325,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd OP: {str(e)}') self.Logs.warning(f'_hcmd OP: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} op [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} op [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -334,7 +334,7 @@ class Command():
# .deop #channel user # .deop #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} deop [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} deop [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -352,7 +352,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd DEOP: {str(e)}') self.Logs.warning(f'_hcmd DEOP: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} deop [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} deop [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -361,7 +361,7 @@ class Command():
# .owner #channel user # .owner #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} owner [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} owner [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -379,7 +379,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd OWNER: {str(e)}') self.Logs.warning(f'_hcmd OWNER: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} owner [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} owner [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -388,7 +388,7 @@ class Command():
# .deowner #channel user # .deowner #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} deowner [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} deowner [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -406,7 +406,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd DEOWNER: {str(e)}') self.Logs.warning(f'_hcmd DEOWNER: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} deowner [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} deowner [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -415,7 +415,7 @@ class Command():
# .protect #channel user # .protect #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -433,7 +433,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd DEOWNER: {str(e)}') self.Logs.warning(f'_hcmd DEOWNER: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -442,7 +442,7 @@ class Command():
# .deprotect #channel user # .deprotect #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -460,7 +460,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd DEOWNER: {str(e)}') self.Logs.warning(f'_hcmd DEOWNER: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -469,7 +469,7 @@ class Command():
# .halfop #channel user # .halfop #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} halfop [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} halfop [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -487,7 +487,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd halfop: {str(e)}') self.Logs.warning(f'_hcmd halfop: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} halfop [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} halfop [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -496,7 +496,7 @@ class Command():
# .dehalfop #channel user # .dehalfop #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} dehalfop [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} dehalfop [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -514,7 +514,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd DEHALFOP: {str(e)}') self.Logs.warning(f'_hcmd DEHALFOP: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} dehalfop [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} dehalfop [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -523,7 +523,7 @@ class Command():
# .voice #channel user # .voice #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} voice [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} voice [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -541,7 +541,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd VOICE: {str(e)}') self.Logs.warning(f'_hcmd VOICE: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} voice [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} voice [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -550,7 +550,7 @@ class Command():
# .devoice #channel user # .devoice #channel user
try: try:
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} devoice [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} devoice [#SALON] [NICKNAME]")
return False return False
if len(cmd) == 1: if len(cmd) == 1:
@@ -568,7 +568,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd DEVOICE: {str(e)}') self.Logs.warning(f'_hcmd DEVOICE: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} devoice [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} devoice [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -577,7 +577,7 @@ class Command():
try: try:
sentchannel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None sentchannel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None
if sentchannel is None: if sentchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]")
return False return False
nickname = cmd[2] nickname = cmd[2]
@@ -586,7 +586,7 @@ class Command():
self.Logs.debug(f'{fromuser} has banned {nickname} from {sentchannel}') self.Logs.debug(f'{fromuser} has banned {nickname} from {sentchannel}')
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd BAN: {str(e)}') self.Logs.warning(f'_hcmd BAN: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -595,7 +595,7 @@ class Command():
try: try:
sentchannel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None sentchannel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None
if sentchannel is None: if sentchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} ban [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} ban [#SALON] [NICKNAME]")
return False return False
nickname = cmd[2] nickname = cmd[2]
@@ -604,7 +604,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd UNBAN: {str(e)}') self.Logs.warning(f'_hcmd UNBAN: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} unban [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} unban [#SALON] [NICKNAME]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -613,7 +613,7 @@ class Command():
try: try:
sentchannel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None sentchannel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None
if sentchannel is None: if sentchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} ban [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} ban [#SALON] [NICKNAME]")
return False return False
nickname = cmd[2] nickname = cmd[2]
final_reason = ' '.join(cmd[3:]) final_reason = ' '.join(cmd[3:])
@@ -623,7 +623,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd KICK: {str(e)}') self.Logs.warning(f'_hcmd KICK: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} kick [#SALON] [NICKNAME] [REASON]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} kick [#SALON] [NICKNAME] [REASON]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -632,7 +632,7 @@ class Command():
try: try:
sentchannel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None sentchannel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None
if sentchannel is None: if sentchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} ban [#SALON] [NICKNAME]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} ban [#SALON] [NICKNAME]")
return False return False
nickname = cmd[2] nickname = cmd[2]
final_reason = ' '.join(cmd[3:]) final_reason = ' '.join(cmd[3:])
@@ -643,7 +643,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd KICKBAN: {str(e)}') self.Logs.warning(f'_hcmd KICKBAN: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} kickban [#SALON] [NICKNAME] [REASON]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} kickban [#SALON] [NICKNAME] [REASON]")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -652,12 +652,12 @@ class Command():
try: try:
sent_channel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None sent_channel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None
if sent_channel is None: if sent_channel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"{self.Config.SERVICE_PREFIX}JOIN #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"{self.Config.SERVICE_PREFIX}JOIN #channel")
return False return False
# self.Protocol.send2socket(f':{service_id} JOIN {sent_channel}') # self.Protocol.send2socket(f':{service_id} JOIN {sent_channel}')
self.Protocol.sendChanJoin(uidornickname=dnickname,channel=sent_channel) self.Protocol.send_join_chan(uidornickname=dnickname,channel=sent_channel)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" {dnickname} JOINED {sent_channel}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" {dnickname} JOINED {sent_channel}")
self.Channel.db_query_channel('add', self.module_name, sent_channel) self.Channel.db_query_channel('add', self.module_name, sent_channel)
except IndexError as ie: except IndexError as ie:
@@ -670,15 +670,15 @@ class Command():
try: try:
sent_channel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None sent_channel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None
if sent_channel is None: if sent_channel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"{self.Config.SERVICE_PREFIX}PART #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"{self.Config.SERVICE_PREFIX}PART #channel")
return False return False
if sent_channel == dchanlog: if sent_channel == dchanlog:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" {dnickname} CAN'T LEFT {sent_channel} AS IT IS LOG CHANNEL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" {dnickname} CAN'T LEFT {sent_channel} AS IT IS LOG CHANNEL")
return False return False
self.Protocol.sendChanPart(uidornickname=dnickname, channel=sent_channel) self.Protocol.send_part_chan(uidornickname=dnickname, channel=sent_channel)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" {dnickname} LEFT {sent_channel}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" {dnickname} LEFT {sent_channel}")
self.Channel.db_query_channel('del', self.module_name, sent_channel) self.Channel.db_query_channel('del', self.module_name, sent_channel)
@@ -690,14 +690,14 @@ class Command():
case 'topic': case 'topic':
try: try:
if len(cmd) == 1: if len(cmd) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} TOPIC #channel THE_TOPIC_MESSAGE") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} TOPIC #channel THE_TOPIC_MESSAGE")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} TOPIC #channel THE_TOPIC_MESSAGE") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} TOPIC #channel THE_TOPIC_MESSAGE")
return None return None
chan = str(cmd[1]) chan = str(cmd[1])
if not self.Channel.Is_Channel(chan): if not self.Channel.Is_Channel(chan):
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"The channel must start with #") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"The channel must start with #")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} TOPIC #channel THE_TOPIC_MESSAGE") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} TOPIC #channel THE_TOPIC_MESSAGE")
return None return None
topic_msg = ' '.join(cmd[2:]).strip() topic_msg = ' '.join(cmd[2:]).strip()
@@ -705,7 +705,7 @@ class Command():
if topic_msg: if topic_msg:
self.Protocol.send2socket(f':{dnickname} TOPIC {chan} :{topic_msg}') self.Protocol.send2socket(f':{dnickname} TOPIC {chan} :{topic_msg}')
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"You need to specify the topic") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"You need to specify the topic")
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
@@ -715,7 +715,7 @@ class Command():
case 'wallops': case 'wallops':
try: try:
if len(cmd) == 1: if len(cmd) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} WALLOPS THE_WALLOPS_MESSAGE") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} WALLOPS THE_WALLOPS_MESSAGE")
return None return None
wallops_msg = ' '.join(cmd[1:]).strip() wallops_msg = ' '.join(cmd[1:]).strip()
@@ -723,7 +723,7 @@ class Command():
if wallops_msg: if wallops_msg:
self.Protocol.send2socket(f':{dnickname} WALLOPS {wallops_msg} ({dnickname})') self.Protocol.send2socket(f':{dnickname} WALLOPS {wallops_msg} ({dnickname})')
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"You need to specify the wallops message") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"You need to specify the wallops message")
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
@@ -733,7 +733,7 @@ class Command():
case 'globops': case 'globops':
try: try:
if len(cmd) == 1: if len(cmd) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} GLOBOPS THE_GLOBOPS_MESSAGE") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} GLOBOPS THE_GLOBOPS_MESSAGE")
return None return None
globops_msg = ' '.join(cmd[1:]).strip() globops_msg = ' '.join(cmd[1:]).strip()
@@ -741,7 +741,7 @@ class Command():
if globops_msg: if globops_msg:
self.Protocol.send2socket(f':{dnickname} GLOBOPS {globops_msg} ({dnickname})') self.Protocol.send2socket(f':{dnickname} GLOBOPS {globops_msg} ({dnickname})')
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"You need to specify the globops message") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"You need to specify the globops message")
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
@@ -751,15 +751,15 @@ class Command():
case 'gnotice': case 'gnotice':
try: try:
if len(cmd) == 1: if len(cmd) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} THE_GLOBAL_NOTICE_MESSAGE") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} THE_GLOBAL_NOTICE_MESSAGE")
return None return None
gnotice_msg = ' '.join(cmd[1:]).strip() gnotice_msg = ' '.join(cmd[1:]).strip()
if gnotice_msg: if gnotice_msg:
self.Protocol.sendNotice(nick_from=dnickname, nick_to='$*.*', msg=f"[{self.Config.COLORS.red}GLOBAL NOTICE{self.Config.COLORS.nogc}] {gnotice_msg}") self.Protocol.send_notice(nick_from=dnickname, nick_to='$*.*', msg=f"[{self.Config.COLORS.red}GLOBAL NOTICE{self.Config.COLORS.nogc}] {gnotice_msg}")
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"You need to specify the global notice message") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"You need to specify the global notice message")
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
@@ -770,14 +770,14 @@ class Command():
try: try:
self.user_to_notice = fromuser self.user_to_notice = fromuser
if len(cmd) == 1: if len(cmd) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
if self.User.get_nickname(nickname) is None: if self.User.get_nickname(nickname) is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Nickname not found !") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Nickname not found !")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME")
return None return None
self.Protocol.send2socket(f':{dnickname} WHOIS {nickname}') self.Protocol.send2socket(f':{dnickname} WHOIS {nickname}')
@@ -790,14 +790,14 @@ class Command():
case 'names': case 'names':
try: try:
if len(cmd) == 1: if len(cmd) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} #CHANNEL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} #CHANNEL")
return None return None
chan = str(cmd[1]) chan = str(cmd[1])
if not self.Channel.Is_Channel(chan): if not self.Channel.Is_Channel(chan):
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"The channel must start with #") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"The channel must start with #")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} #channel")
return None return None
self.Protocol.send2socket(f':{dnickname} NAMES {chan}') self.Protocol.send2socket(f':{dnickname} NAMES {chan}')
@@ -810,20 +810,20 @@ class Command():
case 'invite': case 'invite':
try: try:
if len(cmd) < 3: if len(cmd) < 3:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME #CHANNEL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME #CHANNEL")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
chan = str(cmd[2]) chan = str(cmd[2])
if not self.Channel.Is_Channel(chan): if not self.Channel.Is_Channel(chan):
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"The channel must start with #") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"The channel must start with #")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME #CHANNEL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME #CHANNEL")
return None return None
if self.User.get_nickname(nickname) is None: if self.User.get_nickname(nickname) is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"Nickname not found !") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Nickname not found !")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME #CHANNEL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()} NICKNAME #CHANNEL")
return None return None
self.Protocol.send2socket(f':{dnickname} INVITE {nickname} {chan}') self.Protocol.send2socket(f':{dnickname} INVITE {nickname} {chan}')
@@ -836,7 +836,7 @@ class Command():
case 'inviteme': case 'inviteme':
try: try:
if len(cmd) == 0: if len(cmd) == 0:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {dnickname} {str(cmd[0]).upper()}")
return None return None
self.Protocol.send2socket(f':{dnickname} INVITE {fromuser} {self.Config.SERVICE_CHANLOG}') self.Protocol.send2socket(f':{dnickname} INVITE {fromuser} {self.Config.SERVICE_CHANLOG}')
@@ -860,13 +860,13 @@ class Command():
try: try:
# .umode nickname +mode # .umode nickname +mode
if len(cmd) < 2: if len(cmd) < 2:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [NICKNAME] [+/-]mode") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [NICKNAME] [+/-]mode")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
umode = str(cmd[2]) umode = str(cmd[2])
self.Protocol.sendSvsmode(nickname=nickname, user_mode=umode) self.Protocol.send_svs_mode(nickname=nickname, user_mode=umode)
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
@@ -878,11 +878,11 @@ class Command():
try: try:
if len(cmd) < 2: if len(cmd) < 2:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#CHANNEL] [+/-]mode") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#CHANNEL] [+/-]mode")
return None return None
if fromchannel is None: if fromchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#CHANNEL] [+/-]mode") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#CHANNEL] [+/-]mode")
return None return None
if len(cmd) == 2: if len(cmd) == 2:
@@ -890,7 +890,7 @@ class Command():
if self.Channel.Is_Channel(fromchannel): if self.Channel.Is_Channel(fromchannel):
self.Protocol.send2socket(f":{dnickname} MODE {fromchannel} {channel_mode}") self.Protocol.send2socket(f":{dnickname} MODE {fromchannel} {channel_mode}")
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : Channel [{fromchannel}] is not correct should start with #") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : Channel [{fromchannel}] is not correct should start with #")
return None return None
if len(cmd) == 3: if len(cmd) == 3:
@@ -901,7 +901,7 @@ class Command():
except IndexError as e: except IndexError as e:
self.Logs.warning(f'_hcmd OP: {str(e)}') self.Logs.warning(f'_hcmd OP: {str(e)}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#CHANNEL] [+/-]mode") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#CHANNEL] [+/-]mode")
except Exception as err: except Exception as err:
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
@@ -915,14 +915,14 @@ class Command():
nickname = str(cmd[1]) nickname = str(cmd[1])
channel = str(cmd[2]) channel = str(cmd[2])
if len(cmd) != 3: if len(cmd) != 3:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSJOIN nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSJOIN nickname #channel")
return None return None
self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSJOIN {nickname} {channel}') self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSJOIN {nickname} {channel}')
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSJOIN nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSJOIN nickname #channel")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'svspart': case 'svspart':
@@ -931,14 +931,14 @@ class Command():
nickname = str(cmd[1]) nickname = str(cmd[1])
channel = str(cmd[2]) channel = str(cmd[2])
if len(cmd) != 3: if len(cmd) != 3:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSPART nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSPART nickname #channel")
return None return None
self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSPART {nickname} {channel}') self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSPART {nickname} {channel}')
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSPART nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSPART nickname #channel")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'sajoin': case 'sajoin':
@@ -947,15 +947,15 @@ class Command():
nickname = str(cmd[1]) nickname = str(cmd[1])
channel = str(cmd[2]) channel = str(cmd[2])
if len(cmd) < 3: if len(cmd) < 3:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel")
return None return None
self.Protocol.sendSajoin(nick_to_sajoin=nickname, channel_name=channel) self.Protocol.send_sajoin(nick_to_sajoin=nickname, channel_name=channel)
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'sapart': case 'sapart':
@@ -964,14 +964,14 @@ class Command():
nickname = str(cmd[1]) nickname = str(cmd[1])
channel = str(cmd[2]) channel = str(cmd[2])
if len(cmd) < 3: if len(cmd) < 3:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel")
return None return None
self.Protocol.sendSapart(nick_to_sapart=nickname, channel_name=channel) self.Protocol.send_sapart(nick_to_sapart=nickname, channel_name=channel)
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'svsnick': case 'svsnick':
@@ -982,11 +982,11 @@ class Command():
unixtime = self.Base.get_unixtime() unixtime = self.Base.get_unixtime()
if self.User.get_nickname(nickname) is None: if self.User.get_nickname(nickname) is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" This nickname do not exist") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" This nickname do not exist")
return None return None
if len(cmd) != 3: if len(cmd) != 3:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname newnickname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname newnickname")
return None return None
self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSNICK {nickname} {newnickname} {unixtime}') self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSNICK {nickname} {newnickname} {unixtime}')
@@ -994,7 +994,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname newnickname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname newnickname")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'kill': case 'kill':
@@ -1002,7 +1002,7 @@ class Command():
# 'kill', 'gline', 'ungline', 'shun', 'unshun' # 'kill', 'gline', 'ungline', 'shun', 'unshun'
# .kill nickname reason # .kill nickname reason
if len(cmd) < 3: if len(cmd) < 3:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname reason")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
@@ -1012,7 +1012,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSNICK nickname newnickname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSNICK nickname newnickname")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'gline': case 'gline':
@@ -1020,7 +1020,7 @@ class Command():
# TKL + G user host set_by expire_timestamp set_at_timestamp :reason # TKL + G user host set_by expire_timestamp set_at_timestamp :reason
# .gline [nickname] [host] [reason] # .gline [nickname] [host] [reason]
if len(cmd) < 4: if len(cmd) < 4:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
@@ -1030,8 +1030,8 @@ class Command():
gline_reason = ' '.join(cmd[3:]) gline_reason = ' '.join(cmd[3:])
if nickname == '*' and hostname == '*': if nickname == '*' and hostname == '*':
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" You want to close the server ? i would recommand ./unrealircd stop :)") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" You want to close the server ? i would recommand ./unrealircd stop :)")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
return None return None
self.Protocol.gline(nickname=nickname, hostname=hostname, set_by=dnickname, expire_timestamp=expire_time, set_at_timestamp=set_at_timestamp, reason=gline_reason) self.Protocol.gline(nickname=nickname, hostname=hostname, set_by=dnickname, expire_timestamp=expire_time, set_at_timestamp=set_at_timestamp, reason=gline_reason)
@@ -1039,7 +1039,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'ungline': case 'ungline':
@@ -1048,7 +1048,7 @@ class Command():
# TKL + G user host set_by expire_timestamp set_at_timestamp :reason # TKL + G user host set_by expire_timestamp set_at_timestamp :reason
# .ungline nickname host # .ungline nickname host
if len(cmd) < 2: if len(cmd) < 2:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
@@ -1060,7 +1060,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'kline': case 'kline':
@@ -1068,7 +1068,7 @@ class Command():
# TKL + k user host set_by expire_timestamp set_at_timestamp :reason # TKL + k user host set_by expire_timestamp set_at_timestamp :reason
# .gline [nickname] [host] [reason] # .gline [nickname] [host] [reason]
if len(cmd) < 4: if len(cmd) < 4:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
@@ -1078,8 +1078,8 @@ class Command():
gline_reason = ' '.join(cmd[3:]) gline_reason = ' '.join(cmd[3:])
if nickname == '*' and hostname == '*': if nickname == '*' and hostname == '*':
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" You want to close the server ? i would recommand ./unrealircd stop :)") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" You want to close the server ? i would recommand ./unrealircd stop :)")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
return None return None
self.Protocol.kline(nickname=nickname, hostname=hostname, set_by=dnickname, expire_timestamp=expire_time, set_at_timestamp=set_at_timestamp, reason=gline_reason) self.Protocol.kline(nickname=nickname, hostname=hostname, set_by=dnickname, expire_timestamp=expire_time, set_at_timestamp=set_at_timestamp, reason=gline_reason)
@@ -1087,7 +1087,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'unkline': case 'unkline':
@@ -1096,7 +1096,7 @@ class Command():
# TKL + G user host set_by expire_timestamp set_at_timestamp :reason # TKL + G user host set_by expire_timestamp set_at_timestamp :reason
# .ungline nickname host # .ungline nickname host
if len(cmd) < 2: if len(cmd) < 2:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
@@ -1107,7 +1107,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'shun': case 'shun':
@@ -1116,7 +1116,7 @@ class Command():
# .shun [nickname] [host] [reason] # .shun [nickname] [host] [reason]
if len(cmd) < 4: if len(cmd) < 4:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
@@ -1126,15 +1126,15 @@ class Command():
shun_reason = ' '.join(cmd[3:]) shun_reason = ' '.join(cmd[3:])
if nickname == '*' and hostname == '*': if nickname == '*' and hostname == '*':
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" You want to close the server ? i would recommand ./unrealircd stop :)") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" You want to close the server ? i would recommand ./unrealircd stop :)")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
return None return None
self.Protocol.send2socket(f":{self.Config.SERVEUR_ID} TKL + s {nickname} {hostname} {dnickname} {expire_time} {set_at_timestamp} :{shun_reason}") self.Protocol.send2socket(f":{self.Config.SERVEUR_ID} TKL + s {nickname} {hostname} {dnickname} {expire_time} {set_at_timestamp} :{shun_reason}")
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname host reason")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'unshun': case 'unshun':
@@ -1143,7 +1143,7 @@ class Command():
# TKL + G user host set_by expire_timestamp set_at_timestamp :reason # TKL + G user host set_by expire_timestamp set_at_timestamp :reason
# .unshun nickname host # .unshun nickname host
if len(cmd) < 2: if len(cmd) < 2:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname")
return None return None
nickname = str(cmd[1]) nickname = str(cmd[1])
@@ -1154,7 +1154,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname hostname")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'glinelist': case 'glinelist':
@@ -1165,7 +1165,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()}")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'shunlist': case 'shunlist':
@@ -1176,7 +1176,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()}")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case 'klinelist': case 'klinelist':
@@ -1187,7 +1187,7 @@ class Command():
except KeyError as ke: except KeyError as ke:
self.Logs.error(ke) self.Logs.error(ke)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()}")
self.Logs.warning(f'Unknown Error: {str(err)}') self.Logs.warning(f'Unknown Error: {str(err)}')
case _: case _:

View File

@@ -351,12 +351,12 @@ class Defender():
if not get_reputation.isWebirc: if not get_reputation.isWebirc:
# Si le user ne vient pas de webIrc # Si le user ne vient pas de webIrc
self.Protocol.sendSajoin(nick_to_sajoin=jailed_nickname, channel_name=salon_jail) self.Protocol.send_sajoin(nick_to_sajoin=jailed_nickname, channel_name=salon_jail)
self.Protocol.sendPrivMsg(nick_from=self.Config.SERVICE_NICKNAME, self.Protocol.send_priv_msg(nick_from=self.Config.SERVICE_NICKNAME,
msg=f" [{color_red} REPUTATION {nogc}] : Connexion de {jailed_nickname} ({jailed_score}) ==> {salon_jail}", msg=f" [{color_red} REPUTATION {nogc}] : Connexion de {jailed_nickname} ({jailed_score}) ==> {salon_jail}",
channel=salon_logs channel=salon_logs
) )
self.Protocol.sendNotice( self.Protocol.send_notice(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
nick_to=jailed_nickname, nick_to=jailed_nickname,
msg=f"[{color_red} {jailed_nickname} {color_black}] : Merci de tapez la commande suivante {color_bold}{service_prefix}code {code}{color_bold}" msg=f"[{color_red} {jailed_nickname} {color_black}] : Merci de tapez la commande suivante {color_bold}{service_prefix}code {code}{color_bold}"
@@ -400,7 +400,7 @@ class Defender():
for user in self.Reputation.UID_REPUTATION_DB: for user in self.Reputation.UID_REPUTATION_DB:
if not user.isWebirc: # Si il ne vient pas de WebIRC if not user.isWebirc: # Si il ne vient pas de WebIRC
if self.get_user_uptime_in_minutes(user.uid) >= reputation_timer and int(user.score_connexion) <= int(reputation_seuil): if self.get_user_uptime_in_minutes(user.uid) >= reputation_timer and int(user.score_connexion) <= int(reputation_seuil):
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=service_id, nick_from=service_id,
msg=f"[{color_red} REPUTATION {nogc}] : Action sur {user.nickname} aprés {str(reputation_timer)} minutes d'inactivité", msg=f"[{color_red} REPUTATION {nogc}] : Action sur {user.nickname} aprés {str(reputation_timer)} minutes d'inactivité",
channel=dchanlog channel=dchanlog
@@ -495,7 +495,7 @@ class Defender():
elif self.flood_system[get_detected_uid]['nbr_msg'] > flood_message: elif self.flood_system[get_detected_uid]['nbr_msg'] > flood_message:
self.Irc.Base.logs.info('system de flood detecté') self.Irc.Base.logs.info('system de flood detecté')
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"{color_red} {color_bold} Flood detected. Apply the +m mode (Ô_o)", msg=f"{color_red} {color_bold} Flood detected. Apply the +m mode (Ô_o)",
channel=channel channel=channel
@@ -516,13 +516,13 @@ class Defender():
for param in res.fetchall(): for param in res.fetchall():
if param[0] == 'reputation': if param[0] == 'reputation':
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=service_id, nick_from=service_id,
msg=f" ===> {param[0]}", msg=f" ===> {param[0]}",
channel=dchanlog channel=dchanlog
) )
else: else:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=service_id, nick_from=service_id,
msg=f"{param[0]}", msg=f"{param[0]}",
channel=dchanlog channel=dchanlog
@@ -555,7 +555,7 @@ class Defender():
connection = (remote_ip, self.Base.int_if_possible(port)) connection = (remote_ip, self.Base.int_if_possible(port))
newSocket.connect(connection) newSocket.connect(connection)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[ {self.Config.COLORS.red}PROXY_SCAN{self.Config.COLORS.nogc} ] {fullname} ({remote_ip}) : Port [{str(port)}] ouvert sur l'adresse ip [{remote_ip}]", msg=f"[ {self.Config.COLORS.red}PROXY_SCAN{self.Config.COLORS.nogc} ] {fullname} ({remote_ip}) : Port [{str(port)}] ouvert sur l'adresse ip [{remote_ip}]",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -622,7 +622,7 @@ class Defender():
self.Logs.info(f"Connexion of {fullname} ({remote_ip}) using ports : {str(matching_ports)}") self.Logs.info(f"Connexion of {fullname} ({remote_ip}) using ports : {str(matching_ports)}")
if matching_ports: if matching_ports:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[ {self.Config.COLORS.red}PSUTIL_SCAN{self.Config.COLORS.black} ] {fullname} ({remote_ip}) : is using ports {matching_ports}", msg=f"[ {self.Config.COLORS.red}PSUTIL_SCAN{self.Config.COLORS.black} ] {fullname} ({remote_ip}) : is using ports {matching_ports}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -713,7 +713,7 @@ class Defender():
# pseudo!ident@host # pseudo!ident@host
fullname = f'{nickname}!{username}@{hostname}' fullname = f'{nickname}!{username}@{hostname}'
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=service_id, nick_from=service_id,
msg=f"[ {color_red}ABUSEIPDB_SCAN{nogc} ] : Connexion de {fullname} ({remote_ip}) ==> Score: {str(result['score'])} | Country : {result['country']} | Tor : {str(result['isTor'])} | Total Reports : {str(result['totalReports'])}", msg=f"[ {color_red}ABUSEIPDB_SCAN{nogc} ] : Connexion de {fullname} ({remote_ip}) ==> Score: {str(result['score'])} | Country : {result['country']} | Tor : {str(result['isTor'])} | Total Reports : {str(result['totalReports'])}",
channel=service_chanlog channel=service_chanlog
@@ -811,7 +811,7 @@ class Defender():
# pseudo!ident@host # pseudo!ident@host
fullname = f'{nickname}!{username}@{hostname}' fullname = f'{nickname}!{username}@{hostname}'
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=service_id, nick_from=service_id,
msg=f"[ {color_red}FREEIPAPI_SCAN{nogc} ] : Connexion de {fullname} ({remote_ip}) ==> Proxy: {str(result['isProxy'])} | Country : {str(result['countryCode'])}", msg=f"[ {color_red}FREEIPAPI_SCAN{nogc} ] : Connexion de {fullname} ({remote_ip}) ==> Proxy: {str(result['isProxy'])} | Country : {str(result['countryCode'])}",
channel=service_chanlog channel=service_chanlog
@@ -902,7 +902,7 @@ class Defender():
# pseudo!ident@host # pseudo!ident@host
fullname = f'{nickname}!{username}@{hostname}' fullname = f'{nickname}!{username}@{hostname}'
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=service_id, nick_from=service_id,
msg=f"[ {color_red}CLOUDFILT_SCAN{nogc} ] : Connexion de {fullname} ({remote_ip}) ==> Host: {str(result['host'])} | country: {str(result['countryiso'])} | listed: {str(result['listed'])} | listed by : {str(result['listed_by'])}", msg=f"[ {color_red}CLOUDFILT_SCAN{nogc} ] : Connexion de {fullname} ({remote_ip}) ==> Host: {str(result['host'])} | country: {str(result['countryiso'])} | listed: {str(result['listed'])} | listed by : {str(result['listed_by'])}",
channel=service_chanlog channel=service_chanlog
@@ -1000,7 +1000,7 @@ class Defender():
return None return None
def cmd(self, data: list) -> None: def cmd(self, data: list[str]) -> None:
try: try:
service_id = self.Config.SERVICE_ID # Defender serveur id service_id = self.Config.SERVICE_ID # Defender serveur id
cmd = list(data).copy() cmd = list(data).copy()
@@ -1112,7 +1112,7 @@ class Defender():
if not isWebirc: if not isWebirc:
if parsed_chan != self.Config.SALON_JAIL: if parsed_chan != self.Config.SALON_JAIL:
self.Protocol.sendSapart(nick_to_sapart=get_reputation.nickname, channel_name=parsed_chan) self.Protocol.send_sapart(nick_to_sapart=get_reputation.nickname, channel_name=parsed_chan)
if self.ModConfig.reputation_ban_all_chan == 1 and not isWebirc: if self.ModConfig.reputation_ban_all_chan == 1 and not isWebirc:
if parsed_chan != self.Config.SALON_JAIL: if parsed_chan != self.Config.SALON_JAIL:
@@ -1231,12 +1231,12 @@ class Defender():
case 'show_reputation': case 'show_reputation':
if not self.Reputation.UID_REPUTATION_DB: if not self.Reputation.UID_REPUTATION_DB:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=" No one is suspected") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" No one is suspected")
for suspect in self.Reputation.UID_REPUTATION_DB: for suspect in self.Reputation.UID_REPUTATION_DB:
self.Protocol.sendNotice(nick_from=dnickname, self.Protocol.send_notice(nick_from=dnickname,
nick_to=fromuser, nick_to=fromuser,
msg=f" Uid: {suspect.uid} | Nickname: {suspect.nickname} | Reputation: {suspect.score} | Secret code: {suspect.secret_code} | Connected on: {suspect.connected_datetime}") msg=f" Uid: {suspect.uid} | Nickname: {suspect.nickname} | Reputation: {suspect.score_connexion} | Secret code: {suspect.secret_code} | Connected on: {suspect.connected_datetime}")
case 'code': case 'code':
try: try:
@@ -1246,7 +1246,7 @@ class Defender():
get_reputation = self.Reputation.get_Reputation(jailed_UID) get_reputation = self.Reputation.get_Reputation(jailed_UID)
if get_reputation is None: if get_reputation is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=" No code is requested ...") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" No code is requested ...")
return False return False
jailed_IP = get_reputation.remote_ip jailed_IP = get_reputation.remote_ip
@@ -1260,7 +1260,7 @@ class Defender():
color_black = self.Config.COLORS.black color_black = self.Config.COLORS.black
if release_code == get_reputation.secret_code: if release_code == get_reputation.secret_code:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg="Bon mot de passe. Allez du vent !", channel=jailed_salon) self.Protocol.send_priv_msg(nick_from=dnickname, msg="Bon mot de passe. Allez du vent !", channel=jailed_salon)
if self.ModConfig.reputation_ban_all_chan == 1: if self.ModConfig.reputation_ban_all_chan == 1:
for chan in self.Channel.UID_CHANNEL_DB: for chan in self.Channel.UID_CHANNEL_DB:
@@ -1269,21 +1269,21 @@ class Defender():
self.Reputation.delete(jailed_UID) self.Reputation.delete(jailed_UID)
self.Logs.debug(f'{jailed_UID} - {jailed_nickname} removed from REPUTATION_DB') self.Logs.debug(f'{jailed_UID} - {jailed_nickname} removed from REPUTATION_DB')
self.Protocol.sendSapart(nick_to_sapart=jailed_nickname, channel_name=jailed_salon) self.Protocol.send_sapart(nick_to_sapart=jailed_nickname, channel_name=jailed_salon)
self.Protocol.sendSajoin(nick_to_sajoin=jailed_nickname, channel_name=welcome_salon) self.Protocol.send_sajoin(nick_to_sajoin=jailed_nickname, channel_name=welcome_salon)
self.Protocol.send2socket(f":{link} REPUTATION {jailed_IP} {self.ModConfig.reputation_score_after_release}") self.Protocol.send2socket(f":{link} REPUTATION {jailed_IP} {self.ModConfig.reputation_score_after_release}")
self.User.get_User(jailed_UID).score_connexion = reputation_seuil + 1 self.User.get_User(jailed_UID).score_connexion = reputation_seuil + 1
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"[{color_green} MOT DE PASS CORRECT {color_black}] : You have now the right to enjoy the network !", msg=f"[{color_green} MOT DE PASS CORRECT {color_black}] : You have now the right to enjoy the network !",
nick_to=jailed_nickname) nick_to=jailed_nickname)
else: else:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg="Mauvais password", msg="Mauvais password",
channel=jailed_salon channel=jailed_salon
) )
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[{color_green} MAUVAIS PASSWORD {color_black}] You have typed a wrong code. for recall your password is: {self.Config.SERVICE_PREFIX}code {get_reputation.secret_code}", msg=f"[{color_green} MAUVAIS PASSWORD {color_black}] You have typed a wrong code. for recall your password is: {self.Config.SERVICE_PREFIX}code {get_reputation.secret_code}",
nick_to=jailed_nickname nick_to=jailed_nickname
@@ -1291,7 +1291,7 @@ class Defender():
except IndexError as ie: except IndexError as ie:
self.Logs.error(f'Index Error: {ie}') self.Logs.error(f'Index Error: {ie}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} code [code]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} code [code]")
except KeyError as ke: except KeyError as ke:
self.Logs.error(f'_hcmd code: KeyError {ke}') self.Logs.error(f'_hcmd code: KeyError {ke}')
@@ -1308,16 +1308,16 @@ class Defender():
self.__update_configuration('autolimit', 1) self.__update_configuration('autolimit', 1)
self.autolimit_isRunning = True self.autolimit_isRunning = True
self.Base.create_thread(self.thread_autolimit) self.Base.create_thread(self.thread_autolimit)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Activated", channel=self.Config.SERVICE_CHANLOG) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Activated", channel=self.Config.SERVICE_CHANLOG)
else: else:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[{self.Config.COLORS.red}AUTOLIMIT{self.Config.COLORS.nogc}] Already activated", channel=self.Config.SERVICE_CHANLOG) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[{self.Config.COLORS.red}AUTOLIMIT{self.Config.COLORS.nogc}] Already activated", channel=self.Config.SERVICE_CHANLOG)
case 'off': case 'off':
if self.ModConfig.autolimit == 1: if self.ModConfig.autolimit == 1:
self.__update_configuration('autolimit', 0) self.__update_configuration('autolimit', 0)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Deactivated", channel=self.Config.SERVICE_CHANLOG) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Deactivated", channel=self.Config.SERVICE_CHANLOG)
else: else:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[{self.Config.COLORS.red}AUTOLIMIT{self.Config.COLORS.nogc}] Already Deactivated", channel=self.Config.SERVICE_CHANLOG) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[{self.Config.COLORS.red}AUTOLIMIT{self.Config.COLORS.nogc}] Already Deactivated", channel=self.Config.SERVICE_CHANLOG)
case 'set': case 'set':
amount = int(cmd[2]) amount = int(cmd[2])
@@ -1325,19 +1325,19 @@ class Defender():
self.__update_configuration('autolimit_amount', amount) self.__update_configuration('autolimit_amount', amount)
self.__update_configuration('autolimit_interval', interval) self.__update_configuration('autolimit_interval', interval)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Amount set to ({amount}) | Interval set to ({interval})", msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Amount set to ({amount}) | Interval set to ({interval})",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
) )
case _: case _:
self.Protocol.sendNotice(nick_from=dnickname, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON", nickname=fromuser) self.Protocol.send_notice(nick_from=dnickname, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON", nickname=fromuser)
self.Protocol.sendNotice(nick_from=dnickname, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]", nickname=fromuser) self.Protocol.send_notice(nick_from=dnickname, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]", nickname=fromuser)
except Exception as err: except Exception as err:
self.Protocol.sendNotice(nick_from=dnickname, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON", nickname=fromuser) self.Protocol.send_notice(nick_from=dnickname, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON", nickname=fromuser)
self.Protocol.sendNotice(nick_from=dnickname, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]", nickname=fromuser) self.Protocol.send_notice(nick_from=dnickname, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]", nickname=fromuser)
self.Logs.error(f"Value Error -> {err}") self.Logs.error(f"Value Error -> {err}")
case 'reputation': case 'reputation':
@@ -1355,15 +1355,15 @@ class Defender():
if activation == 'on': if activation == 'on':
if self.ModConfig.reputation == 1: if self.ModConfig.reputation == 1:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Already activated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Already activated", channel=dchanlog)
return False return False
# self.update_db_configuration('reputation', 1) # self.update_db_configuration('reputation', 1)
self.__update_configuration(key, 1) self.__update_configuration(key, 1)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Activated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Activated by {fromuser}", channel=dchanlog)
self.Protocol.sendChanJoin(uidornickname=dnickname, channel=jail_chan) self.Protocol.send_join_chan(uidornickname=dnickname, channel=jail_chan)
self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} +{dumodes} {dnickname}") self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} +{dumodes} {dnickname}")
self.Protocol.send2socket(f":{service_id} MODE {jail_chan} +{jail_chan_mode}") self.Protocol.send2socket(f":{service_id} MODE {jail_chan} +{jail_chan_mode}")
@@ -1378,7 +1378,7 @@ class Defender():
if activation == 'off': if activation == 'off':
if self.ModConfig.reputation == 0: if self.ModConfig.reputation == 0:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Already deactivated", msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Already deactivated",
channel=dchanlog channel=dchanlog
@@ -1387,7 +1387,7 @@ class Defender():
self.__update_configuration(key, 0) self.__update_configuration(key, 0)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.red}REPUTATION{self.Config.COLORS.black} ] : Deactivated by {fromuser}", msg=f"[ {self.Config.COLORS.red}REPUTATION{self.Config.COLORS.black} ] : Deactivated by {fromuser}",
channel=dchanlog channel=dchanlog
@@ -1419,7 +1419,7 @@ class Defender():
if get_value == 'on': if get_value == 'on':
if self.ModConfig.reputation_ban_all_chan == 1: if self.ModConfig.reputation_ban_all_chan == 1:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already activated", msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already activated",
channel=dchanlog channel=dchanlog
@@ -1429,7 +1429,7 @@ class Defender():
# self.update_db_configuration(key, 1) # self.update_db_configuration(key, 1)
self.__update_configuration(key, 1) self.__update_configuration(key, 1)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Activated by {fromuser}", msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Activated by {fromuser}",
channel=dchanlog channel=dchanlog
@@ -1437,7 +1437,7 @@ class Defender():
elif get_value == 'off': elif get_value == 'off':
if self.ModConfig.reputation_ban_all_chan == 0: if self.ModConfig.reputation_ban_all_chan == 0:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already deactivated", msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already deactivated",
channel=dchanlog channel=dchanlog
@@ -1447,7 +1447,7 @@ class Defender():
# self.update_db_configuration(key, 0) # self.update_db_configuration(key, 0)
self.__update_configuration(key, 0) self.__update_configuration(key, 0)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Deactivated by {fromuser}", msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Deactivated by {fromuser}",
channel=dchanlog channel=dchanlog
@@ -1460,69 +1460,69 @@ class Defender():
# self.update_db_configuration(key, reputation_seuil) # self.update_db_configuration(key, reputation_seuil)
self.__update_configuration(key, reputation_seuil) self.__update_configuration(key, reputation_seuil)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}REPUTATION SEUIL{self.Config.COLORS.black} ] : Limit set to {str(reputation_seuil)} by {fromuser}", msg=f"[ {self.Config.COLORS.green}REPUTATION SEUIL{self.Config.COLORS.black} ] : Limit set to {str(reputation_seuil)} by {fromuser}",
channel=dchanlog channel=dchanlog
) )
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation set to {reputation_seuil}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation set to {reputation_seuil}")
case 'timer': case 'timer':
reputation_timer = int(cmd[3]) reputation_timer = int(cmd[3])
key = 'reputation_timer' key = 'reputation_timer'
self.__update_configuration(key, reputation_timer) self.__update_configuration(key, reputation_timer)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}REPUTATION TIMER{self.Config.COLORS.black} ] : Timer set to {str(reputation_timer)} minute(s) by {fromuser}", msg=f"[ {self.Config.COLORS.green}REPUTATION TIMER{self.Config.COLORS.black} ] : Timer set to {str(reputation_timer)} minute(s) by {fromuser}",
channel=dchanlog channel=dchanlog
) )
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation set to {reputation_timer}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation set to {reputation_timer}")
case 'score_after_release': case 'score_after_release':
reputation_score_after_release = int(cmd[3]) reputation_score_after_release = int(cmd[3])
key = 'reputation_score_after_release' key = 'reputation_score_after_release'
self.__update_configuration(key, reputation_score_after_release) self.__update_configuration(key, reputation_score_after_release)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}REPUTATION SCORE AFTER RELEASE{self.Config.COLORS.black} ] : Reputation score after release set to {str(reputation_score_after_release)} by {fromuser}", msg=f"[ {self.Config.COLORS.green}REPUTATION SCORE AFTER RELEASE{self.Config.COLORS.black} ] : Reputation score after release set to {str(reputation_score_after_release)} by {fromuser}",
channel=dchanlog channel=dchanlog
) )
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation score after release set to {reputation_score_after_release}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation score after release set to {reputation_score_after_release}")
case 'security_group': case 'security_group':
reputation_sg = int(cmd[3]) reputation_sg = int(cmd[3])
key = 'reputation_sg' key = 'reputation_sg'
self.__update_configuration(key, reputation_sg) self.__update_configuration(key, reputation_sg)
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}REPUTATION SECURITY-GROUP{self.Config.COLORS.black} ] : Reputation Security-group set to {str(reputation_sg)} by {fromuser}", msg=f"[ {self.Config.COLORS.green}REPUTATION SECURITY-GROUP{self.Config.COLORS.black} ] : Reputation Security-group set to {str(reputation_sg)} by {fromuser}",
channel=dchanlog channel=dchanlog
) )
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation score after release set to {reputation_sg}") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation score after release set to {reputation_sg}")
case _: case _:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation [ON/OFF]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation [ON/OFF]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set banallchan [ON/OFF]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set banallchan [ON/OFF]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set limit [1234]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set limit [1234]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set score_after_release [1234]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set score_after_release [1234]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set timer [1234]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set timer [1234]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set action [kill|None]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set action [kill|None]")
except IndexError as ie: except IndexError as ie:
self.Logs.warning(f'{ie}') self.Logs.warning(f'{ie}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation [ON/OFF]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation [ON/OFF]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set banallchan [ON/OFF]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set banallchan [ON/OFF]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set limit [1234]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set limit [1234]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set score_after_release [1234]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set score_after_release [1234]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set timer [1234]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set timer [1234]")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set action [kill|None]") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set action [kill|None]")
except ValueError as ve: except ValueError as ve:
self.Logs.warning(f'{ve}') self.Logs.warning(f'{ve}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" La valeur devrait etre un entier >= 0") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" La valeur devrait etre un entier >= 0")
case 'proxy_scan': case 'proxy_scan':
@@ -1538,11 +1538,11 @@ class Defender():
set_key = str(cmd[1]).lower() set_key = str(cmd[1]).lower()
if set_key != 'set': if set_key != 'set':
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]')
option = str(cmd[2]).lower() # => local_scan, psutil_scan, abuseipdb_scan option = str(cmd[2]).lower() # => local_scan, psutil_scan, abuseipdb_scan
action = str(cmd[3]).lower() # => on / off action = str(cmd[3]).lower() # => on / off
@@ -1551,105 +1551,105 @@ class Defender():
case 'local_scan': case 'local_scan':
if action == 'on': if action == 'on':
if self.ModConfig.local_scan == 1: if self.ModConfig.local_scan == 1:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
return None return None
self.__update_configuration(option, 1) self.__update_configuration(option, 1)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
elif action == 'off': elif action == 'off':
if self.ModConfig.local_scan == 0: if self.ModConfig.local_scan == 0:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
return None return None
self.__update_configuration(option, 0) self.__update_configuration(option, 0)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
case 'psutil_scan': case 'psutil_scan':
if action == 'on': if action == 'on':
if self.ModConfig.psutil_scan == 1: if self.ModConfig.psutil_scan == 1:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
return None return None
self.__update_configuration(option, 1) self.__update_configuration(option, 1)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
elif action == 'off': elif action == 'off':
if self.ModConfig.psutil_scan == 0: if self.ModConfig.psutil_scan == 0:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
return None return None
self.__update_configuration(option, 0) self.__update_configuration(option, 0)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
case 'abuseipdb_scan': case 'abuseipdb_scan':
if action == 'on': if action == 'on':
if self.ModConfig.abuseipdb_scan == 1: if self.ModConfig.abuseipdb_scan == 1:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
return None return None
self.__update_configuration(option, 1) self.__update_configuration(option, 1)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
elif action == 'off': elif action == 'off':
if self.ModConfig.abuseipdb_scan == 0: if self.ModConfig.abuseipdb_scan == 0:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
return None return None
self.__update_configuration(option, 0) self.__update_configuration(option, 0)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
case 'freeipapi_scan': case 'freeipapi_scan':
if action == 'on': if action == 'on':
if self.ModConfig.freeipapi_scan == 1: if self.ModConfig.freeipapi_scan == 1:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
return None return None
self.__update_configuration(option, 1) self.__update_configuration(option, 1)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
elif action == 'off': elif action == 'off':
if self.ModConfig.freeipapi_scan == 0: if self.ModConfig.freeipapi_scan == 0:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
return None return None
self.__update_configuration(option, 0) self.__update_configuration(option, 0)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
case 'cloudfilt_scan': case 'cloudfilt_scan':
if action == 'on': if action == 'on':
if self.ModConfig.cloudfilt_scan == 1: if self.ModConfig.cloudfilt_scan == 1:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
return None return None
self.__update_configuration(option, 1) self.__update_configuration(option, 1)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
elif action == 'off': elif action == 'off':
if self.ModConfig.cloudfilt_scan == 0: if self.ModConfig.cloudfilt_scan == 0:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
return None return None
self.__update_configuration(option, 0) self.__update_configuration(option, 0)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
case _: case _:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]')
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]')
case 'flood': case 'flood':
# .flood on/off # .flood on/off
@@ -1664,21 +1664,21 @@ class Defender():
key = 'flood' key = 'flood'
if activation == 'on': if activation == 'on':
if self.ModConfig.flood == 1: if self.ModConfig.flood == 1:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Already activated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Already activated", channel=dchanlog)
return False return False
self.__update_configuration(key, 1) self.__update_configuration(key, 1)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Activated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Activated by {fromuser}", channel=dchanlog)
if activation == 'off': if activation == 'off':
if self.ModConfig.flood == 0: if self.ModConfig.flood == 0:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.red}FLOOD{self.Config.COLORS.black} ] : Already Deactivated", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.red}FLOOD{self.Config.COLORS.black} ] : Already Deactivated", channel=dchanlog)
return False return False
self.__update_configuration(key, 0) self.__update_configuration(key, 0)
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Deactivated by {fromuser}", channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Deactivated by {fromuser}", channel=dchanlog)
if len_cmd == 4: if len_cmd == 4:
set_key = str(cmd[2]).lower() set_key = str(cmd[2]).lower()
@@ -1690,7 +1690,7 @@ class Defender():
set_value = int(cmd[3]) set_value = int(cmd[3])
self.__update_configuration(key, set_value) self.__update_configuration(key, set_value)
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood message set to {set_value} by {fromuser}", msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood message set to {set_value} by {fromuser}",
channel=dchanlog) channel=dchanlog)
@@ -1699,7 +1699,7 @@ class Defender():
set_value = int(cmd[3]) set_value = int(cmd[3])
self.__update_configuration(key, set_value) self.__update_configuration(key, set_value)
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood time set to {set_value} by {fromuser}", msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood time set to {set_value} by {fromuser}",
channel=dchanlog) channel=dchanlog)
@@ -1708,7 +1708,7 @@ class Defender():
set_value = int(cmd[3]) set_value = int(cmd[3])
self.__update_configuration(key, set_value) self.__update_configuration(key, set_value)
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood timer set to {set_value} by {fromuser}", msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood timer set to {set_value} by {fromuser}",
channel=dchanlog) channel=dchanlog)
@@ -1724,22 +1724,22 @@ class Defender():
color_black = self.Config.COLORS.black color_black = self.Config.COLORS.black
nogc = self.Config.COLORS.nogc nogc = self.Config.COLORS.nogc
try: try:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' [{color_green if self.ModConfig.reputation == 1 else color_red}Reputation{nogc}] ==> {self.ModConfig.reputation}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' [{color_green if self.ModConfig.reputation == 1 else color_red}Reputation{nogc}] ==> {self.ModConfig.reputation}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_seuil ==> {self.ModConfig.reputation_seuil}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_seuil ==> {self.ModConfig.reputation_seuil}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_after_release ==> {self.ModConfig.reputation_score_after_release}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_after_release ==> {self.ModConfig.reputation_score_after_release}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_ban_all_chan ==> {self.ModConfig.reputation_ban_all_chan}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_ban_all_chan ==> {self.ModConfig.reputation_ban_all_chan}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_timer ==> {self.ModConfig.reputation_timer}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_timer ==> {self.ModConfig.reputation_timer}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' [Proxy_scan]') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' [Proxy_scan]')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.local_scan == 1 else color_red}local_scan{nogc} ==> {self.ModConfig.local_scan}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.local_scan == 1 else color_red}local_scan{nogc} ==> {self.ModConfig.local_scan}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.psutil_scan == 1 else color_red}psutil_scan{nogc} ==> {self.ModConfig.psutil_scan}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.psutil_scan == 1 else color_red}psutil_scan{nogc} ==> {self.ModConfig.psutil_scan}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.abuseipdb_scan == 1 else color_red}abuseipdb_scan{nogc} ==> {self.ModConfig.abuseipdb_scan}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.abuseipdb_scan == 1 else color_red}abuseipdb_scan{nogc} ==> {self.ModConfig.abuseipdb_scan}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.freeipapi_scan == 1 else color_red}freeipapi_scan{nogc} ==> {self.ModConfig.freeipapi_scan}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.freeipapi_scan == 1 else color_red}freeipapi_scan{nogc} ==> {self.ModConfig.freeipapi_scan}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.cloudfilt_scan == 1 else color_red}cloudfilt_scan{nogc} ==> {self.ModConfig.cloudfilt_scan}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.cloudfilt_scan == 1 else color_red}cloudfilt_scan{nogc} ==> {self.ModConfig.cloudfilt_scan}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' [{color_green if self.ModConfig.flood == 1 else color_red}Flood{nogc}] ==> {self.ModConfig.flood}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' [{color_green if self.ModConfig.flood == 1 else color_red}Flood{nogc}] ==> {self.ModConfig.flood}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_action ==> Coming soon') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_action ==> Coming soon')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_message ==> {self.ModConfig.flood_message}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_message ==> {self.ModConfig.flood_message}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_time ==> {self.ModConfig.flood_time}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_time ==> {self.ModConfig.flood_time}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_timer ==> {self.ModConfig.flood_timer}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_timer ==> {self.ModConfig.flood_timer}')
except KeyError as ke: except KeyError as ke:
self.Logs.error(f"Key Error : {ke}") self.Logs.error(f"Key Error : {ke}")
@@ -1755,22 +1755,22 @@ class Defender():
if self.Base.clean_uid(uid_in_chan) == UserObject.uid: if self.Base.clean_uid(uid_in_chan) == UserObject.uid:
channels.append(chan.name) channels.append(chan.name)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' UID : {UserObject.uid}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' UID : {UserObject.uid}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' NICKNAME : {UserObject.nickname}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' NICKNAME : {UserObject.nickname}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' USERNAME : {UserObject.username}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' USERNAME : {UserObject.username}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' REALNAME : {UserObject.realname}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' REALNAME : {UserObject.realname}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' HOSTNAME : {UserObject.hostname}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' HOSTNAME : {UserObject.hostname}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' VHOST : {UserObject.vhost}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' VHOST : {UserObject.vhost}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' IP : {UserObject.remote_ip}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' IP : {UserObject.remote_ip}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' Country : {UserObject.geoip}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Country : {UserObject.geoip}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' WebIrc : {UserObject.isWebirc}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' WebIrc : {UserObject.isWebirc}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' WebWebsocket : {UserObject.isWebsocket}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' WebWebsocket : {UserObject.isWebsocket}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' REPUTATION : {UserObject.score_connexion}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' REPUTATION : {UserObject.score_connexion}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' MODES : {UserObject.umodes}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' MODES : {UserObject.umodes}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' CHANNELS : {channels}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' CHANNELS : {channels}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f' CONNECTION TIME : {UserObject.connexion_datetime}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' CONNECTION TIME : {UserObject.connexion_datetime}')
else: else:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f":{dnickname} NOTICE {fromuser} : This user {nickoruid} doesn't exist") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f":{dnickname} NOTICE {fromuser} : This user {nickoruid} doesn't exist")
except KeyError as ke: except KeyError as ke:
self.Logs.warning(f"Key error info user : {ke}") self.Logs.warning(f"Key error info user : {ke}")
@@ -1785,7 +1785,7 @@ class Defender():
if activation == 'on': if activation == 'on':
for chan in self.Channel.UID_CHANNEL_DB: for chan in self.Channel.UID_CHANNEL_DB:
if not chan.name in channel_to_dont_quit: if not chan.name in channel_to_dont_quit:
self.Protocol.sendChanJoin(uidornickname=dnickname, channel=chan.name) self.Protocol.send_join_chan(uidornickname=dnickname, channel=chan.name)
if activation == 'off': if activation == 'off':
for chan in self.Channel.UID_CHANNEL_DB: for chan in self.Channel.UID_CHANNEL_DB:
if not chan.name in channel_to_dont_quit: if not chan.name in channel_to_dont_quit:

View File

@@ -91,14 +91,14 @@ class Jsonrpc():
self.subscribed = False self.subscribed = False
if self.Rpc.Error.code != 0: if self.Rpc.Error.code != 0:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.Rpc.Error.message}", msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.Rpc.Error.message}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
) )
if self.UnrealIrcdRpcLive.Error.code != 0: if self.UnrealIrcdRpcLive.Error.code != 0:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.UnrealIrcdRpcLive.Error.message}", msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.UnrealIrcdRpcLive.Error.message}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -153,7 +153,7 @@ class Jsonrpc():
red = self.Config.COLORS.red red = self.Config.COLORS.red
if json_response.result == True: if json_response.result == True:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[{bold}{green}JSONRPC{nogc}{bold}] Event activated", msg=f"[{bold}{green}JSONRPC{nogc}{bold}] Event activated",
channel=dchanlog) channel=dchanlog)
@@ -167,7 +167,7 @@ class Jsonrpc():
build_msg = f"{green}{log_source}{nogc}: [{bold}{level}{bold}] {subsystem}.{event_id} - {msg}" build_msg = f"{green}{log_source}{nogc}: [{bold}{level}{bold}] {subsystem}.{event_id} - {msg}"
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=build_msg, channel=dchanlog) self.Protocol.send_priv_msg(nick_from=dnickname, msg=build_msg, channel=dchanlog)
def thread_start_jsonrpc(self): def thread_start_jsonrpc(self):
@@ -175,7 +175,7 @@ class Jsonrpc():
self.UnrealIrcdRpcLive.subscribe(["all"]) self.UnrealIrcdRpcLive.subscribe(["all"])
self.subscribed = True self.subscribed = True
else: else:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.UnrealIrcdRpcLive.Error.message}", msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.UnrealIrcdRpcLive.Error.message}",
channel=self.Config.SERVICE_CHANLOG channel=self.Config.SERVICE_CHANLOG
@@ -229,8 +229,8 @@ class Jsonrpc():
option = str(cmd[1]).lower() option = str(cmd[1]).lower()
if len(command) == 1: if len(command) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'/msg {dnickname} jsonrpc on') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'/msg {dnickname} jsonrpc on')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'/msg {dnickname} jsonrpc off') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'/msg {dnickname} jsonrpc off')
match option: match option:
@@ -238,13 +238,13 @@ class Jsonrpc():
for thread in self.Base.running_threads: for thread in self.Base.running_threads:
if thread.getName() == 'thread_start_jsonrpc': if thread.getName() == 'thread_start_jsonrpc':
if thread.is_alive(): if thread.is_alive():
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Thread {thread.getName()} is running", msg=f"Thread {thread.getName()} is running",
channel=dchannel channel=dchannel
) )
else: else:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=self.Config.SERVICE_NICKNAME, nick_from=self.Config.SERVICE_NICKNAME,
msg=f"Thread {thread.getName()} is not running, wait untill the process will be cleaned up", msg=f"Thread {thread.getName()} is not running, wait untill the process will be cleaned up",
channel=dchannel channel=dchannel
@@ -265,7 +265,7 @@ class Jsonrpc():
option = str(cmd[1]).lower() option = str(cmd[1]).lower()
if len(command) == 1: if len(command) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'/msg {dnickname} jruser get nickname') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'/msg {dnickname} jruser get nickname')
match option: match option:
@@ -279,37 +279,37 @@ class Jsonrpc():
UserInfo = rpc.User.get(uid_to_get) UserInfo = rpc.User.get(uid_to_get)
if rpc.Error.code != 0: if rpc.Error.code != 0:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'{rpc.Error.message}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'{rpc.Error.message}')
return None return None
chan_list = [] chan_list = []
for chan in UserInfo.user.channels: for chan in UserInfo.user.channels:
chan_list.append(chan.name) chan_list.append(chan.name)
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'UID : {UserInfo.id}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'UID : {UserInfo.id}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'NICKNAME : {UserInfo.name}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'NICKNAME : {UserInfo.name}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'USERNAME : {UserInfo.user.username}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'USERNAME : {UserInfo.user.username}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'REALNAME : {UserInfo.user.realname}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'REALNAME : {UserInfo.user.realname}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'MODES : {UserInfo.user.modes}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'MODES : {UserInfo.user.modes}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'CHANNELS : {chan_list}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'CHANNELS : {chan_list}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'SECURITY GROUP : {UserInfo.user.security_groups}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'SECURITY GROUP : {UserInfo.user.security_groups}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'REPUTATION : {UserInfo.user.reputation}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'REPUTATION : {UserInfo.user.reputation}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'IP : {UserInfo.ip}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'IP : {UserInfo.ip}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'COUNTRY CODE : {UserInfo.geoip.country_code}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'COUNTRY CODE : {UserInfo.geoip.country_code}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'ASN : {UserInfo.geoip.asn}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'ASN : {UserInfo.geoip.asn}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'ASNAME : {UserInfo.geoip.asname}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'ASNAME : {UserInfo.geoip.asname}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'CLOAKED HOST : {UserInfo.user.cloakedhost}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'CLOAKED HOST : {UserInfo.user.cloakedhost}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'HOSTNAME : {UserInfo.hostname}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'HOSTNAME : {UserInfo.hostname}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'VHOST : {UserInfo.user.vhost}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'VHOST : {UserInfo.user.vhost}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'CLIENT PORT : {UserInfo.client_port}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'CLIENT PORT : {UserInfo.client_port}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'SERVER PORT : {UserInfo.server_port}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'SERVER PORT : {UserInfo.server_port}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'CERTFP : {UserInfo.tls.certfp}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'CERTFP : {UserInfo.tls.certfp}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'CIPHER : {UserInfo.tls.cipher}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'CIPHER : {UserInfo.tls.cipher}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'IDLE SINCE : {UserInfo.idle_since}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'IDLE SINCE : {UserInfo.idle_since}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f'CONNECTED SINCE : {UserInfo.connected_since}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'CONNECTED SINCE : {UserInfo.connected_since}')
except IndexError as ie: except IndexError as ie:
self.Logs.error(ie) self.Logs.error(ie)
@@ -319,11 +319,11 @@ class Jsonrpc():
self.Base.create_thread(self.thread_ask_ia, ('',)) self.Base.create_thread(self.thread_ask_ia, ('',))
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg=f" This is a notice to the sender ...") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" This is a notice to the sender ...")
self.Protocol.sendPrivMsg(nick_from=dnickname, msg="This is private message to the sender ...", nick_to=fromuser) self.Protocol.send_priv_msg(nick_from=dnickname, msg="This is private message to the sender ...", nick_to=fromuser)
if not fromchannel is None: if not fromchannel is None:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg="This is channel message to the sender ...", channel=fromchannel) self.Protocol.send_priv_msg(nick_from=dnickname, msg="This is channel message to the sender ...", channel=fromchannel)
# How to update your module configuration # How to update your module configuration
self.__update_configuration('param_exemple2', 7) self.__update_configuration('param_exemple2', 7)

View File

@@ -159,11 +159,11 @@ class Test():
case 'test-command': case 'test-command':
try: try:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser, msg="This is a notice to the sender ...") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg="This is a notice to the sender ...")
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"This is private message to the sender ...", nick_to=fromuser) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"This is private message to the sender ...", nick_to=fromuser)
if not fromchannel is None: if not fromchannel is None:
self.Protocol.sendPrivMsg(nick_from=dnickname, msg=f"This is private message to the sender ...", channel=fromchannel) self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"This is private message to the sender ...", channel=fromchannel)
# How to update your module configuration # How to update your module configuration
self.__update_configuration('param_exemple2', 7) self.__update_configuration('param_exemple2', 7)

View File

@@ -122,7 +122,7 @@ class Votekick():
def unload(self) -> None: def unload(self) -> None:
try: try:
for chan in self.VOTE_CHANNEL_DB: for chan in self.VOTE_CHANNEL_DB:
self.Protocol.sendChanPart(uidornickname=self.Config.SERVICE_ID, channel=chan.channel_name) self.Protocol.send_part_chan(uidornickname=self.Config.SERVICE_ID, channel=chan.channel_name)
self.VOTE_CHANNEL_DB = [] self.VOTE_CHANNEL_DB = []
self.Logs.debug(f'Delete memory DB VOTE_CHANNEL_DB: {self.VOTE_CHANNEL_DB}') self.Logs.debug(f'Delete memory DB VOTE_CHANNEL_DB: {self.VOTE_CHANNEL_DB}')
@@ -238,7 +238,7 @@ class Votekick():
if chan.channel_name == channel: if chan.channel_name == channel:
target_user = self.User.get_nickname(chan.target_user) target_user = self.User.get_nickname(chan.target_user)
if chan.vote_for > chan.vote_against: if chan.vote_for > chan.vote_against:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"User {self.Config.COLORS.bold}{target_user}{self.Config.COLORS.nogc} has {chan.vote_against} votes against and {chan.vote_for} votes for. For this reason, it'll be kicked from the channel", msg=f"User {self.Config.COLORS.bold}{target_user}{self.Config.COLORS.nogc} has {chan.vote_against} votes against and {chan.vote_for} votes for. For this reason, it'll be kicked from the channel",
channel=channel channel=channel
@@ -246,7 +246,7 @@ class Votekick():
self.Protocol.send2socket(f":{dnickname} KICK {channel} {target_user} Following the vote, you are not welcome in {channel}") self.Protocol.send2socket(f":{dnickname} KICK {channel} {target_user} Following the vote, you are not welcome in {channel}")
self.Channel.delete_user_from_channel(channel, self.User.get_uid(target_user)) self.Channel.delete_user_from_channel(channel, self.User.get_uid(target_user))
elif chan.vote_for <= chan.vote_against: elif chan.vote_for <= chan.vote_against:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"User {self.Config.COLORS.bold}{target_user}{self.Config.COLORS.nogc} has {chan.vote_against} votes against and {chan.vote_for} votes for. For this reason, it\'ll remain in the channel", msg=f"User {self.Config.COLORS.bold}{target_user}{self.Config.COLORS.nogc} has {chan.vote_against} votes against and {chan.vote_for} votes for. For this reason, it\'ll remain in the channel",
channel=channel channel=channel
@@ -254,7 +254,7 @@ class Votekick():
# Init the system # Init the system
if self.init_vote_system(channel): if self.init_vote_system(channel):
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg="System vote re initiated", msg="System vote re initiated",
channel=channel channel=channel
@@ -288,14 +288,14 @@ class Votekick():
case 'vote': case 'vote':
if len(cmd) == 1: if len(cmd) == 1:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote activate #channel') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote activate #channel')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote deactivate #channel') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote deactivate #channel')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote +') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote +')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote -') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote -')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote cancel') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote cancel')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote status') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote status')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote submit nickname') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote submit nickname')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote verdict') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote verdict')
return None return None
option = str(cmd[1]).lower() option = str(cmd[1]).lower()
@@ -306,12 +306,12 @@ class Votekick():
try: try:
# vote activate #channel # vote activate #channel
if self.Admin.get_Admin(fromuser) is None: if self.Admin.get_Admin(fromuser) is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' :Your are not allowed to execute this command') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' :Your are not allowed to execute this command')
return None return None
sentchannel = str(cmd[2]).lower() if self.Channel.Is_Channel(str(cmd[2]).lower()) else None sentchannel = str(cmd[2]).lower() if self.Channel.Is_Channel(str(cmd[2]).lower()) else None
if sentchannel is None: if sentchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f" The correct command is {self.Config.SERVICE_PREFIX}{command} {option} #CHANNEL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f" The correct command is {self.Config.SERVICE_PREFIX}{command} {option} #CHANNEL")
self.insert_vote_channel( self.insert_vote_channel(
self.VoteChannelModel( self.VoteChannelModel(
@@ -325,30 +325,30 @@ class Votekick():
self.Channel.db_query_channel('add', self.module_name, sentchannel) self.Channel.db_query_channel('add', self.module_name, sentchannel)
self.Protocol.sendChanJoin(uidornickname=dnickname, channel=sentchannel) self.Protocol.send_join_chan(uidornickname=dnickname, channel=sentchannel)
self.Protocol.send2socket(f":{dnickname} SAMODE {sentchannel} +o {dnickname}") self.Protocol.send2socket(f":{dnickname} SAMODE {sentchannel} +o {dnickname}")
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg="You can now use !submit <nickname> to decide if he will stay or not on this channel ", msg="You can now use !submit <nickname> to decide if he will stay or not on this channel ",
channel=sentchannel channel=sentchannel
) )
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option} #channel') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option} #channel')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option} #welcome') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option} #welcome')
case 'deactivate': case 'deactivate':
try: try:
# vote deactivate #channel # vote deactivate #channel
if self.Admin.get_Admin(fromuser) is None: if self.Admin.get_Admin(fromuser) is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f" Your are not allowed to execute this command") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f" Your are not allowed to execute this command")
return None return None
sentchannel = str(cmd[2]).lower() if self.Channel.Is_Channel(str(cmd[2]).lower()) else None sentchannel = str(cmd[2]).lower() if self.Channel.Is_Channel(str(cmd[2]).lower()) else None
if sentchannel is None: if sentchannel is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f" The correct command is {self.Config.SERVICE_PREFIX}{command} {option} #CHANNEL") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f" The correct command is {self.Config.SERVICE_PREFIX}{command} {option} #CHANNEL")
self.Protocol.send2socket(f":{dnickname} SAMODE {sentchannel} -o {dnickname}") self.Protocol.send2socket(f":{dnickname} SAMODE {sentchannel} -o {dnickname}")
self.Protocol.sendChanPart(uidornickname=dnickname, channel=sentchannel) self.Protocol.send_part_chan(uidornickname=dnickname, channel=sentchannel)
for chan in self.VOTE_CHANNEL_DB: for chan in self.VOTE_CHANNEL_DB:
if chan.channel_name == sentchannel: if chan.channel_name == sentchannel:
@@ -358,8 +358,8 @@ class Votekick():
self.Logs.debug(f"The Channel {sentchannel} has been deactivated from the vote system") self.Logs.debug(f"The Channel {sentchannel} has been deactivated from the vote system")
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f" /msg {dnickname} {command} {option} #channel") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f" /msg {dnickname} {command} {option} #channel")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f" Exemple /msg {dnickname} {command} {option} #welcome") self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f" Exemple /msg {dnickname} {command} {option} #welcome")
case '+': case '+':
try: try:
@@ -368,21 +368,21 @@ class Votekick():
for chan in self.VOTE_CHANNEL_DB: for chan in self.VOTE_CHANNEL_DB:
if chan.channel_name == channel: if chan.channel_name == channel:
if fromuser in chan.voter_users: if fromuser in chan.voter_users:
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg="You already submitted a vote", msg="You already submitted a vote",
channel=channel channel=channel
) )
else: else:
chan.vote_for += 1 chan.vote_for += 1
chan.voter_users.append(fromuser) chan.voter_users.append(fromuser)
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg="Vote recorded, thank you", msg="Vote recorded, thank you",
channel=channel channel=channel
) )
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}')
case '-': case '-':
try: try:
@@ -391,65 +391,65 @@ class Votekick():
for chan in self.VOTE_CHANNEL_DB: for chan in self.VOTE_CHANNEL_DB:
if chan.channel_name == channel: if chan.channel_name == channel:
if fromuser in chan.voter_users: if fromuser in chan.voter_users:
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg="You already submitted a vote", msg="You already submitted a vote",
channel=channel channel=channel
) )
else: else:
chan.vote_against += 1 chan.vote_against += 1
chan.voter_users.append(fromuser) chan.voter_users.append(fromuser)
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg="Vote recorded, thank you", msg="Vote recorded, thank you",
channel=channel channel=channel
) )
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}')
case 'cancel': case 'cancel':
try: try:
# vote cancel # vote cancel
if self.Admin.get_Admin(fromuser) is None: if self.Admin.get_Admin(fromuser) is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Your are not allowed to execute this command') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Your are not allowed to execute this command')
return None return None
if channel is None: if channel is None:
self.Logs.error(f"The channel is not known, defender can't cancel the vote") self.Logs.error(f"The channel is not known, defender can't cancel the vote")
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' You need to specify the channel => /msg {dnickname} vote_cancel #channel') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' You need to specify the channel => /msg {dnickname} vote_cancel #channel')
for vote in self.VOTE_CHANNEL_DB: for vote in self.VOTE_CHANNEL_DB:
if vote.channel_name == channel: if vote.channel_name == channel:
self.init_vote_system(channel) self.init_vote_system(channel)
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg="Vote system re-initiated", msg="Vote system re-initiated",
channel=channel channel=channel
) )
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}')
case 'status': case 'status':
try: try:
# vote status # vote status
for chan in self.VOTE_CHANNEL_DB: for chan in self.VOTE_CHANNEL_DB:
if chan.channel_name == channel: if chan.channel_name == channel:
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"Channel: {chan.channel_name} | Target: {self.User.get_nickname(chan.target_user)} | For: {chan.vote_for} | Against: {chan.vote_against} | Number of voters: {str(len(chan.voter_users))}", msg=f"Channel: {chan.channel_name} | Target: {self.User.get_nickname(chan.target_user)} | For: {chan.vote_for} | Against: {chan.vote_against} | Number of voters: {str(len(chan.voter_users))}",
channel=channel channel=channel
) )
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}')
case 'submit': case 'submit':
try: try:
# vote submit nickname # vote submit nickname
if self.Admin.get_Admin(fromuser) is None: if self.Admin.get_Admin(fromuser) is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Your are not allowed to execute this command') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Your are not allowed to execute this command')
return None return None
nickname_submitted = cmd[2] nickname_submitted = cmd[2]
@@ -462,7 +462,7 @@ class Votekick():
if vote.channel_name == channel: if vote.channel_name == channel:
ongoing_user = self.User.get_nickname(vote.target_user) ongoing_user = self.User.get_nickname(vote.target_user)
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"There is an ongoing vote on {ongoing_user}", msg=f"There is an ongoing vote on {ongoing_user}",
channel=channel channel=channel
) )
@@ -470,7 +470,7 @@ class Votekick():
# check if the user exist # check if the user exist
if user_submitted is None: if user_submitted is None:
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"This nickname <{nickname_submitted}> do not exist", msg=f"This nickname <{nickname_submitted}> do not exist",
channel=channel channel=channel
) )
@@ -479,7 +479,7 @@ class Votekick():
uid_cleaned = self.Base.clean_uid(uid_submitted) uid_cleaned = self.Base.clean_uid(uid_submitted)
ChannelInfo = self.Channel.get_Channel(channel) ChannelInfo = self.Channel.get_Channel(channel)
if ChannelInfo is None: if ChannelInfo is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' This channel [{channel}] do not exist in the Channel Object') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' This channel [{channel}] do not exist in the Channel Object')
return False return False
clean_uids_in_channel: list = [] clean_uids_in_channel: list = []
@@ -487,7 +487,7 @@ class Votekick():
clean_uids_in_channel.append(self.Base.clean_uid(uid)) clean_uids_in_channel.append(self.Base.clean_uid(uid))
if not uid_cleaned in clean_uids_in_channel: if not uid_cleaned in clean_uids_in_channel:
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"This nickname <{nickname_submitted}> is not available in this channel", msg=f"This nickname <{nickname_submitted}> is not available in this channel",
channel=channel channel=channel
) )
@@ -497,7 +497,7 @@ class Votekick():
pattern = fr'[o|B|S]' pattern = fr'[o|B|S]'
operator_user = re.findall(pattern, user_submitted.umodes) operator_user = re.findall(pattern, user_submitted.umodes)
if operator_user: if operator_user:
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg="You cant vote for this user ! he/she is protected", msg="You cant vote for this user ! he/she is protected",
channel=channel channel=channel
) )
@@ -507,40 +507,40 @@ class Votekick():
if chan.channel_name == channel: if chan.channel_name == channel:
chan.target_user = self.User.get_uid(nickname_submitted) chan.target_user = self.User.get_uid(nickname_submitted)
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"{nickname_submitted} has been targeted for a vote", msg=f"{nickname_submitted} has been targeted for a vote",
channel=channel channel=channel
) )
self.Base.create_timer(60, self.timer_vote_verdict, (channel, )) self.Base.create_timer(60, self.timer_vote_verdict, (channel, ))
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg="This vote will end after 60 secondes", msg="This vote will end after 60 secondes",
channel=channel channel=channel
) )
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option} nickname') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option} nickname')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option} adator') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option} adator')
case 'verdict': case 'verdict':
try: try:
# vote verdict # vote verdict
if self.Admin.get_Admin(fromuser) is None: if self.Admin.get_Admin(fromuser) is None:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f'Your are not allowed to execute this command') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f'Your are not allowed to execute this command')
return None return None
for chan in self.VOTE_CHANNEL_DB: for chan in self.VOTE_CHANNEL_DB:
if chan.channel_name == channel: if chan.channel_name == channel:
target_user = self.User.get_nickname(chan.target_user) target_user = self.User.get_nickname(chan.target_user)
if chan.vote_for > chan.vote_against: if chan.vote_for > chan.vote_against:
self.Protocol.sendPrivMsg(nick_from=dnickname, self.Protocol.send_priv_msg(nick_from=dnickname,
msg=f"User {self.Config.COLORS.bold}{target_user}{self.Config.COLORS.nogc} has {chan.vote_against} votes against and {chan.vote_for} votes for. For this reason, it\'ll be kicked from the channel", msg=f"User {self.Config.COLORS.bold}{target_user}{self.Config.COLORS.nogc} has {chan.vote_against} votes against and {chan.vote_for} votes for. For this reason, it\'ll be kicked from the channel",
channel=channel channel=channel
) )
self.Protocol.send2socket(f":{dnickname} KICK {channel} {target_user} Following the vote, you are not welcome in {channel}") self.Protocol.send2socket(f":{dnickname} KICK {channel} {target_user} Following the vote, you are not welcome in {channel}")
elif chan.vote_for <= chan.vote_against: elif chan.vote_for <= chan.vote_against:
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg=f"User {self.Config.COLORS.bold}{target_user}{self.Config.COLORS.nogc} has {chan.vote_against} votes against and {chan.vote_for} votes for. For this reason, it\'ll remain in the channel", msg=f"User {self.Config.COLORS.bold}{target_user}{self.Config.COLORS.nogc} has {chan.vote_against} votes against and {chan.vote_for} votes for. For this reason, it\'ll remain in the channel",
channel=channel channel=channel
@@ -548,22 +548,22 @@ class Votekick():
# Init the system # Init the system
if self.init_vote_system(channel): if self.init_vote_system(channel):
self.Protocol.sendPrivMsg( self.Protocol.send_priv_msg(
nick_from=dnickname, nick_from=dnickname,
msg="System vote re initiated", msg="System vote re initiated",
channel=channel channel=channel
) )
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} {command} {option}')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' Exemple /msg {dnickname} {command} {option}')
case _: case _:
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote activate #channel') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote activate #channel')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote deactivate #channel') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote deactivate #channel')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote +') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote +')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote -') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote -')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote cancel') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote cancel')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote status') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote status')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote submit nickname') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote submit nickname')
self.Protocol.sendNotice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote verdict') self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser,msg=f' /msg {dnickname} vote verdict')