mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 11:14:23 +00:00
V6.2.1 Adding main module utils and rehash utils to manager reload/rehash/restart
This commit is contained in:
@@ -177,7 +177,7 @@ def create_new_clone(uplink: 'Clone', faker_instance: 'Faker', group: str = 'Def
|
||||
def handle_on_privmsg(uplink: 'Clone', srvmsg: list[str]):
|
||||
|
||||
uid_sender = uplink.Irc.Utils.clean_uid(srvmsg[1])
|
||||
senderObj = uplink.User.get_User(uid_sender)
|
||||
senderObj = uplink.User.get_user(uid_sender)
|
||||
|
||||
if senderObj.hostname in uplink.Config.CLONE_LOG_HOST_EXEMPT:
|
||||
return
|
||||
|
||||
@@ -277,7 +277,7 @@ class Command:
|
||||
return None
|
||||
|
||||
user_uid = self.User.clean_uid(cmd[5])
|
||||
userObj: MUser = self.User.get_User(user_uid)
|
||||
userObj: MUser = self.User.get_user(user_uid)
|
||||
channel_name = cmd[4] if self.Channel.is_valid_channel(cmd[4]) else None
|
||||
client_obj = self.Client.get_Client(user_uid)
|
||||
nickname = userObj.nickname if userObj is not None else None
|
||||
@@ -291,12 +291,13 @@ class Command:
|
||||
if 'r' not in userObj.umodes and 'o' not in userObj.umodes and not self.Client.is_exist(userObj.uid):
|
||||
return None
|
||||
|
||||
db_data: dict[str, str] = {"nickname": nickname, "channel": channel_name}
|
||||
db_query = self.Base.db_execute_query("SELECT id, mode FROM command_automode WHERE nickname = :nickname AND channel = :channel", db_data)
|
||||
db_data: dict[str, str] = {"nickname": nickname.lower(), "channel": channel_name.lower()}
|
||||
db_query = self.Base.db_execute_query("SELECT id, mode FROM command_automode WHERE LOWER(nickname) = :nickname AND LOWER(channel) = :channel", db_data)
|
||||
db_result = db_query.fetchone()
|
||||
if db_result is not None:
|
||||
if db_result:
|
||||
id, mode = db_result
|
||||
self.Protocol.send2socket(f":{self.Config.SERVICE_ID} MODE {channel_name} {mode} {userObj.nickname}")
|
||||
|
||||
except KeyError as ke:
|
||||
self.Logs.error(f"Key Error: {err}")
|
||||
|
||||
@@ -477,15 +478,18 @@ class Command:
|
||||
try:
|
||||
self.mod_utils.set_assign_channel_to_service(self, cmd, fromuser)
|
||||
except IndexError as ie:
|
||||
self.Logs.debug(f'{ie}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON]")
|
||||
except Exception as err:
|
||||
self.Logs.warning(f'Unknown Error: {str(err)}')
|
||||
|
||||
case 'part' | 'unassign':
|
||||
try:
|
||||
# Syntax. !part #channel
|
||||
self.mod_utils.set_unassign_channel_to_service(self, cmd, fromuser)
|
||||
except IndexError as ie:
|
||||
self.Logs.error(f'{ie}')
|
||||
self.Logs.debug(f'{ie}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} {command.upper()} [#SALON]")
|
||||
except Exception as err:
|
||||
self.Logs.warning(f'Unknown Error: {str(err)}')
|
||||
|
||||
@@ -668,7 +672,7 @@ class Command:
|
||||
nickname = str(cmd[1])
|
||||
umode = str(cmd[2])
|
||||
|
||||
self.Protocol.send_svs_mode(nickname=nickname, user_mode=umode)
|
||||
self.Protocol.send_svsmode(nickname=nickname, user_mode=umode)
|
||||
except KeyError as ke:
|
||||
self.Logs.error(ke)
|
||||
except Exception as err:
|
||||
@@ -715,34 +719,64 @@ class Command:
|
||||
|
||||
case 'svsjoin':
|
||||
try:
|
||||
# .svsjoin nickname #channel
|
||||
nickname = str(cmd[1])
|
||||
channel = str(cmd[2])
|
||||
if len(cmd) != 3:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSJOIN nickname #channel")
|
||||
# SVSJOIN <nick> <channel>[,<channel2>..] [key1[,key2[..]]]
|
||||
if len(cmd) < 4:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSJOIN <nick> <channel>[,<channel2>..] [key1[,key2[..]]]")
|
||||
return None
|
||||
|
||||
self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSJOIN {nickname} {channel}')
|
||||
except KeyError as ke:
|
||||
nickname = str(cmd[1])
|
||||
channels = str(cmd[2]).split(',')
|
||||
keys = str(cmd[3]).split(',')
|
||||
|
||||
self.Protocol.send_svsjoin(nickname, channels, keys)
|
||||
except IndexError as ke:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSJOIN <nick> <channel>[,<channel2>..] [key1[,key2[..]]]")
|
||||
self.Logs.error(ke)
|
||||
except Exception as err:
|
||||
self.Protocol.send_notice(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 <nick> <channel>[,<channel2>..] [key1[,key2[..]]]")
|
||||
self.Logs.warning(f'Unknown Error: {str(err)}')
|
||||
|
||||
case 'svspart':
|
||||
try:
|
||||
# svspart nickname #channel
|
||||
nickname = str(cmd[1])
|
||||
channel = str(cmd[2])
|
||||
if len(cmd) != 3:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSPART nickname #channel")
|
||||
# SVSPART <nick> <channel>[,<channel2>..] [<comment>]
|
||||
if len(cmd) < 4:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSPART <nick> <channel>[,<channel2>..] [<comment>]")
|
||||
return None
|
||||
|
||||
self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSPART {nickname} {channel}')
|
||||
except KeyError as ke:
|
||||
nickname = str(cmd[1])
|
||||
channels = str(cmd[2]).split(',')
|
||||
reason = ' '.join(cmd[3:])
|
||||
|
||||
self.Protocol.send_svspart(nickname, channels, reason)
|
||||
except IndexError as ke:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} SVSPART <nick> <channel>[,<channel2>..] [<comment>]")
|
||||
self.Logs.error(ke)
|
||||
except Exception as err:
|
||||
self.Protocol.send_notice(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 <nick> <channel>[,<channel2>..] [<comment>]")
|
||||
self.Logs.warning(f'Unknown Error: {str(err)}')
|
||||
|
||||
case 'svsnick':
|
||||
try:
|
||||
# .svsnick nickname newnickname
|
||||
nickname = str(cmd[1])
|
||||
newnickname = str(cmd[2])
|
||||
unixtime = self.MainUtils.get_unixtime()
|
||||
|
||||
if self.User.get_nickname(nickname) is None:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" This nickname do not exist")
|
||||
return None
|
||||
|
||||
if len(cmd) != 3:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname newnickname")
|
||||
return None
|
||||
|
||||
self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSNICK {nickname} {newnickname} {unixtime}')
|
||||
|
||||
except IndexError as ke:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname newnickname")
|
||||
self.Logs.error(ke)
|
||||
except Exception as err:
|
||||
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)}')
|
||||
|
||||
case 'sajoin':
|
||||
@@ -779,29 +813,6 @@ class Command:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname #channel")
|
||||
self.Logs.error(f'Unknown Error: {str(err)}')
|
||||
|
||||
case 'svsnick':
|
||||
try:
|
||||
# .svsnick nickname newnickname
|
||||
nickname = str(cmd[1])
|
||||
newnickname = str(cmd[2])
|
||||
unixtime = self.MainUtils.get_unixtime()
|
||||
|
||||
if self.User.get_nickname(nickname) is None:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" This nickname do not exist")
|
||||
return None
|
||||
|
||||
if len(cmd) != 3:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" /msg {dnickname} {command.upper()} nickname newnickname")
|
||||
return None
|
||||
|
||||
self.Protocol.send2socket(f':{self.Config.SERVEUR_ID} SVSNICK {nickname} {newnickname} {unixtime}')
|
||||
|
||||
except KeyError as ke:
|
||||
self.Logs.error(ke)
|
||||
except Exception as err:
|
||||
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)}')
|
||||
|
||||
case 'kill':
|
||||
try:
|
||||
# 'kill', 'gline', 'ungline', 'shun', 'unshun'
|
||||
|
||||
@@ -201,6 +201,9 @@ def set_kickban(uplink: 'Command', cmd: list[str], client: str) -> None:
|
||||
|
||||
def set_assign_channel_to_service(uplink: 'Command', cmd: list[str], client: str) -> None:
|
||||
|
||||
if len(cmd) < 2:
|
||||
raise IndexError(f"{cmd[0].upper()} is expecting the channel parameter")
|
||||
|
||||
command = str(cmd[0])
|
||||
dnickname = uplink.Config.SERVICE_NICKNAME
|
||||
sent_channel = str(cmd[1]) if uplink.Channel.is_valid_channel(cmd[1]) else None
|
||||
@@ -217,6 +220,9 @@ def set_assign_channel_to_service(uplink: 'Command', cmd: list[str], client: str
|
||||
|
||||
def set_unassign_channel_to_service(uplink: 'Command', cmd: list[str], client: str) -> None:
|
||||
|
||||
if len(cmd) < 2:
|
||||
raise IndexError(f"{cmd[0].upper()} is expecting the channel parameter")
|
||||
|
||||
command = str(cmd[0])
|
||||
dnickname = uplink.Config.SERVICE_NICKNAME
|
||||
dchanlog = uplink.Config.SERVICE_CHANLOG
|
||||
|
||||
@@ -273,11 +273,12 @@ class Defender:
|
||||
return None
|
||||
|
||||
def cmd(self, data: list[str]) -> None:
|
||||
try:
|
||||
if not data or len(data) < 2:
|
||||
return None
|
||||
|
||||
cmd = data.copy() if isinstance(data, list) else list(data).copy()
|
||||
if not data or len(data) < 2:
|
||||
return None
|
||||
cmd = data.copy() if isinstance(data, list) else list(data).copy()
|
||||
|
||||
try:
|
||||
index, command = self.Irc.Protocol.get_ircd_protocol_poisition(cmd)
|
||||
if index == -1:
|
||||
return None
|
||||
@@ -398,7 +399,7 @@ class Defender:
|
||||
self.Protocol.send_sapart(nick_to_sapart=jailed_nickname, channel_name=jailed_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.User.get_User(jailed_UID).score_connexion = reputation_seuil + 1
|
||||
self.User.get_user(jailed_UID).score_connexion = reputation_seuil + 1
|
||||
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 !",
|
||||
nick_to=jailed_nickname)
|
||||
@@ -547,7 +548,7 @@ class Defender:
|
||||
link = self.Config.SERVEUR_LINK
|
||||
jailed_salon = self.Config.SALON_JAIL
|
||||
welcome_salon = self.Config.SALON_LIBERER
|
||||
client_obj = self.User.get_User(str(cmd[2]))
|
||||
client_obj = self.User.get_user(str(cmd[2]))
|
||||
|
||||
if client_obj is None:
|
||||
p.send_notice(nick_from=dnickname,
|
||||
@@ -936,7 +937,7 @@ class Defender:
|
||||
return None
|
||||
|
||||
nickoruid = cmd[1]
|
||||
UserObject = self.User.get_User(nickoruid)
|
||||
UserObject = self.User.get_user(nickoruid)
|
||||
|
||||
if UserObject is not None:
|
||||
channels: list = [chan.name for chan in self.Channel.UID_CHANNEL_DB for uid_in_chan in chan.uids if self.Loader.Utils.clean_uid(uid_in_chan) == UserObject.uid]
|
||||
|
||||
@@ -213,7 +213,7 @@ def handle_on_uid(uplink: 'Defender', srvmsg: list[str]):
|
||||
return None
|
||||
|
||||
# Get User information
|
||||
_User = irc.User.get_User(str(srvmsg[8]))
|
||||
_User = irc.User.get_user(str(srvmsg[8]))
|
||||
|
||||
if _User is None:
|
||||
irc.Logs.warning(f'This UID: [{srvmsg[8]}] is not available please check why')
|
||||
@@ -263,7 +263,7 @@ def action_on_flood(uplink: 'Defender', srvmsg: list[str]):
|
||||
|
||||
user_trigger = str(srvmsg[1]).replace(':','')
|
||||
channel = srvmsg[3]
|
||||
User = irc.User.get_User(user_trigger)
|
||||
User = irc.User.get_user(user_trigger)
|
||||
|
||||
if User is None or not irc.Channel.is_valid_channel(channel_to_check=channel):
|
||||
return
|
||||
|
||||
@@ -318,7 +318,7 @@ class Votekick:
|
||||
|
||||
nickname_submitted = cmd[2]
|
||||
uid_submitted = self.User.get_uid(nickname_submitted)
|
||||
user_submitted = self.User.get_User(nickname_submitted)
|
||||
user_submitted = self.User.get_user(nickname_submitted)
|
||||
ongoing_user = None
|
||||
|
||||
# check if there is an ongoing vote
|
||||
|
||||
@@ -144,7 +144,7 @@ class VotekickManager:
|
||||
votec = self.get_vote_channel_model(channel_name)
|
||||
|
||||
if votec:
|
||||
client_obj = self.uplink.User.get_User(votec.target_user)
|
||||
client_obj = self.uplink.User.get_user(votec.target_user)
|
||||
client_to_punish = votec.target_user if client_obj is None else client_obj.nickname
|
||||
if nickname in votec.voter_users:
|
||||
self.Logs.debug(f"[VOTEKICK MANAGER] This nickname ({nickname}) has already voted for ({client_to_punish})")
|
||||
|
||||
Reference in New Issue
Block a user