mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 11:14:23 +00:00
First commit asyncio
This commit is contained in:
@@ -53,7 +53,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send2socket(self, message: str, print_log: bool = True) -> None:
|
||||
async def send2socket(self, message: str, print_log: bool = True) -> None:
|
||||
"""Envoit les commandes à envoyer au serveur.
|
||||
|
||||
Args:
|
||||
@@ -62,7 +62,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_priv_msg(self, nick_from: str, msg: str, channel: str = None, nick_to: str = None):
|
||||
async 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
|
||||
could be either channel or nickname not both together
|
||||
Args:
|
||||
@@ -73,7 +73,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_notice(self, nick_from: str, nick_to: str, msg: str) -> None:
|
||||
async def send_notice(self, nick_from: str, nick_to: str, msg: str) -> None:
|
||||
"""Sending NOTICE by batches
|
||||
|
||||
Args:
|
||||
@@ -83,13 +83,13 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_link(self) -> None:
|
||||
async def send_link(self) -> None:
|
||||
"""Créer le link et envoyer les informations nécessaires pour la
|
||||
connexion au serveur.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_gline(self, nickname: str, hostname: str, set_by: str, expire_timestamp: int, set_at_timestamp: int, reason: str) -> None:
|
||||
async def send_gline(self, nickname: str, hostname: str, set_by: str, expire_timestamp: int, set_at_timestamp: int, reason: str) -> None:
|
||||
"""Send a gline command to the server
|
||||
|
||||
Args:
|
||||
@@ -102,7 +102,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_set_nick(self, newnickname: str) -> None:
|
||||
async def send_set_nick(self, newnickname: str) -> None:
|
||||
"""Change nickname of the server
|
||||
\n This method will also update the User object
|
||||
Args:
|
||||
@@ -110,7 +110,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_set_mode(self, modes: str, *, nickname: Optional[str] = None, channel_name: Optional[str] = None, params: Optional[str] = None) -> None:
|
||||
async def send_set_mode(self, modes: str, *, nickname: Optional[str] = None, channel_name: Optional[str] = None, params: Optional[str] = None) -> None:
|
||||
"""Set a mode to channel or to a nickname or for a user in a channel
|
||||
|
||||
Args:
|
||||
@@ -121,7 +121,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_squit(self, server_id: str, server_link: str, reason: str) -> None:
|
||||
async def send_squit(self, server_id: str, server_link: str, reason: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -131,7 +131,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_ungline(self, nickname:str, hostname: str) -> None:
|
||||
async def send_ungline(self, nickname:str, hostname: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -140,7 +140,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_kline(self, nickname: str, hostname: str, set_by: str, expire_timestamp: int, set_at_timestamp: int, reason: str) -> None:
|
||||
async def send_kline(self, nickname: str, hostname: str, set_by: str, expire_timestamp: int, set_at_timestamp: int, reason: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -153,7 +153,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_unkline(self, nickname:str, hostname: str) -> None:
|
||||
async def send_unkline(self, nickname:str, hostname: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -162,7 +162,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_sjoin(self, channel: str) -> None:
|
||||
async def send_sjoin(self, channel: str) -> None:
|
||||
"""Server will join a channel with pre defined umodes
|
||||
|
||||
Args:
|
||||
@@ -170,7 +170,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_sapart(self, nick_to_sapart: str, channel_name: str) -> None:
|
||||
async def send_sapart(self, nick_to_sapart: str, channel_name: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -179,7 +179,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_sajoin(self, nick_to_sajoin: str, channel_name: str) -> None:
|
||||
async def send_sajoin(self, nick_to_sajoin: str, channel_name: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -188,7 +188,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_svspart(self, nick_to_part: str, channels: list[str], reason: str) -> None:
|
||||
async def send_svspart(self, nick_to_part: str, channels: list[str], reason: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -198,7 +198,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_svsjoin(self, nick_to_part: str, channels: list[str], keys: list[str]) -> None:
|
||||
async def send_svsjoin(self, nick_to_part: str, channels: list[str], keys: list[str]) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -208,7 +208,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_svsmode(self, nickname: str, user_mode: str) -> None:
|
||||
async def send_svsmode(self, nickname: str, user_mode: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -217,7 +217,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_svs2mode(self, nickname: str, user_mode: str) -> None:
|
||||
async def send_svs2mode(self, nickname: str, user_mode: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -226,7 +226,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_svslogin(self, client_uid: str, user_account: str) -> None:
|
||||
async def send_svslogin(self, client_uid: str, user_account: str) -> None:
|
||||
"""Log a client into his account.
|
||||
|
||||
Args:
|
||||
@@ -235,7 +235,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_svslogout(self, client_obj: 'MClient') -> None:
|
||||
async def send_svslogout(self, client_obj: 'MClient') -> None:
|
||||
"""Logout a client from his account
|
||||
|
||||
Args:
|
||||
@@ -243,7 +243,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_quit(self, uid: str, reason: str, print_log: bool = True) -> None:
|
||||
async def send_quit(self, uid: str, reason: str, print_log: bool = True) -> None:
|
||||
"""Send quit message
|
||||
- Delete uid from User object
|
||||
- Delete uid from Reputation object
|
||||
@@ -255,7 +255,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
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:
|
||||
async 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
|
||||
- Insert User to User Object
|
||||
Args:
|
||||
@@ -271,7 +271,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_join_chan(self, uidornickname: str, channel: str, password: str = None, print_log: bool = True) -> None:
|
||||
async def send_join_chan(self, uidornickname: str, channel: str, password: str = None, print_log: bool = True) -> None:
|
||||
"""Joining a channel
|
||||
|
||||
Args:
|
||||
@@ -282,7 +282,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_part_chan(self, uidornickname:str, channel: str, print_log: bool = True) -> None:
|
||||
async def send_part_chan(self, uidornickname:str, channel: str, print_log: bool = True) -> None:
|
||||
"""Part from a channel
|
||||
|
||||
Args:
|
||||
@@ -292,7 +292,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_mode_chan(self, channel_name: str, channel_mode: str) -> None:
|
||||
async def send_mode_chan(self, channel_name: str, channel_mode: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -301,7 +301,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def send_raw(self, raw_command: str) -> None:
|
||||
async def send_raw(self, raw_command: str) -> None:
|
||||
"""Send raw message to the server
|
||||
|
||||
Args:
|
||||
@@ -313,7 +313,7 @@ class IProtocol(ABC):
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
@abstractmethod
|
||||
def parse_uid(self, server_msg: list[str]) -> Optional['MUser']:
|
||||
async def parse_uid(self, server_msg: list[str]) -> Optional['MUser']:
|
||||
"""Parse UID and return dictionary.
|
||||
|
||||
Args:
|
||||
@@ -324,7 +324,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def parse_quit(self, server_msg: list[str]) -> tuple[Optional['MUser'], str]:
|
||||
async def parse_quit(self, server_msg: list[str]) -> tuple[Optional['MUser'], str]:
|
||||
"""Parse quit and return dictionary.
|
||||
>>> [':97KAAAAAB', 'QUIT', ':Quit:', 'this', 'is', 'my', 'reason', 'to', 'quit']
|
||||
Args:
|
||||
@@ -335,7 +335,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def parse_nick(self, server_msg: list[str]) -> tuple[Optional['MUser'], str, str]:
|
||||
async def parse_nick(self, server_msg: list[str]) -> tuple[Optional['MUser'], str, str]:
|
||||
"""Parse nick changes and return dictionary.
|
||||
>>> [':97KAAAAAC', 'NICK', 'testinspir', '1757360740']
|
||||
|
||||
@@ -349,7 +349,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def parse_privmsg(self, server_msg: list[str]) -> tuple[Optional['MUser'], Optional['MUser'], Optional['MChannel'], str]:
|
||||
async def parse_privmsg(self, server_msg: list[str]) -> tuple[Optional['MUser'], Optional['MUser'], Optional['MChannel'], str]:
|
||||
"""Parse PRIVMSG message.
|
||||
>>> [':97KAAAAAE', 'PRIVMSG', '#welcome', ':This', 'is', 'my', 'public', 'message']
|
||||
|
||||
@@ -365,7 +365,7 @@ class IProtocol(ABC):
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
@abstractmethod
|
||||
def on_svs2mode(self, server_msg: list[str]) -> None:
|
||||
async def on_svs2mode(self, server_msg: list[str]) -> None:
|
||||
"""Handle svs2mode coming from a server
|
||||
>>> [':00BAAAAAG', 'SVS2MODE', '001U01R03', '-r']
|
||||
|
||||
@@ -374,7 +374,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_mode(self, server_msg: list[str]) -> None:
|
||||
async def on_mode(self, server_msg: list[str]) -> None:
|
||||
"""Handle mode coming from a server
|
||||
|
||||
Args:
|
||||
@@ -382,7 +382,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_umode2(self, server_msg: list[str]) -> None:
|
||||
async def on_umode2(self, server_msg: list[str]) -> None:
|
||||
"""Handle umode2 coming from a server
|
||||
>>> [':adator_', 'UMODE2', '-i']
|
||||
|
||||
@@ -391,7 +391,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_quit(self, server_msg: list[str]) -> None:
|
||||
async def on_quit(self, server_msg: list[str]) -> None:
|
||||
"""Handle quit coming from a server
|
||||
|
||||
Args:
|
||||
@@ -399,7 +399,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_squit(self, server_msg: list[str]) -> None:
|
||||
async def on_squit(self, server_msg: list[str]) -> None:
|
||||
"""Handle squit coming from a server
|
||||
|
||||
Args:
|
||||
@@ -407,7 +407,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_protoctl(self, server_msg: list[str]) -> None:
|
||||
async def on_protoctl(self, server_msg: list[str]) -> None:
|
||||
"""Handle protoctl coming from a server
|
||||
|
||||
Args:
|
||||
@@ -415,7 +415,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_nick(self, server_msg: list[str]) -> None:
|
||||
async def on_nick(self, server_msg: list[str]) -> None:
|
||||
"""Handle nick coming from a server
|
||||
new nickname
|
||||
|
||||
@@ -424,7 +424,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_sjoin(self, server_msg: list[str]) -> None:
|
||||
async def on_sjoin(self, server_msg: list[str]) -> None:
|
||||
"""Handle sjoin coming from a server
|
||||
|
||||
Args:
|
||||
@@ -432,7 +432,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_part(self, server_msg: list[str]) -> None:
|
||||
async def on_part(self, server_msg: list[str]) -> None:
|
||||
"""Handle part coming from a server
|
||||
|
||||
Args:
|
||||
@@ -440,7 +440,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_eos(self, server_msg: list[str]) -> None:
|
||||
async def on_eos(self, server_msg: list[str]) -> None:
|
||||
"""Handle EOS coming from a server
|
||||
|
||||
Args:
|
||||
@@ -448,7 +448,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_reputation(self, server_msg: list[str]) -> None:
|
||||
async def on_reputation(self, server_msg: list[str]) -> None:
|
||||
"""Handle REPUTATION coming from a server
|
||||
|
||||
Args:
|
||||
@@ -456,7 +456,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_uid(self, server_msg: list[str]) -> None:
|
||||
async def on_uid(self, server_msg: list[str]) -> None:
|
||||
"""Handle uid message coming from the server
|
||||
|
||||
Args:
|
||||
@@ -464,7 +464,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_privmsg(self, server_msg: list[str]) -> None:
|
||||
async def on_privmsg(self, server_msg: list[str]) -> None:
|
||||
"""Handle PRIVMSG message coming from the server
|
||||
|
||||
Args:
|
||||
@@ -472,7 +472,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_server_ping(self, server_msg: list[str]) -> None:
|
||||
async def on_server_ping(self, server_msg: list[str]) -> None:
|
||||
"""Send a PONG message to the server
|
||||
|
||||
Args:
|
||||
@@ -480,7 +480,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_server(self, server_msg: list[str]) -> None:
|
||||
async def on_server(self, server_msg: list[str]) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -488,7 +488,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_version(self, server_msg: list[str]) -> None:
|
||||
async def on_version(self, server_msg: list[str]) -> None:
|
||||
"""Sending Server Version to the server
|
||||
|
||||
Args:
|
||||
@@ -496,7 +496,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_time(self, server_msg: list[str]) -> None:
|
||||
async def on_time(self, server_msg: list[str]) -> None:
|
||||
"""Sending TIME answer to a requestor
|
||||
|
||||
Args:
|
||||
@@ -504,7 +504,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_ping(self, server_msg: list[str]) -> None:
|
||||
async def on_ping(self, server_msg: list[str]) -> None:
|
||||
"""Sending a PING answer to requestor
|
||||
|
||||
Args:
|
||||
@@ -512,7 +512,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_version_msg(self, server_msg: list[str]) -> None:
|
||||
async def on_version_msg(self, server_msg: list[str]) -> None:
|
||||
"""Handle version coming from the server
|
||||
\n ex. /version Defender
|
||||
Args:
|
||||
@@ -520,7 +520,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_smod(self, server_msg: list[str]) -> None:
|
||||
async def on_smod(self, server_msg: list[str]) -> None:
|
||||
"""Handle SMOD message coming from the server
|
||||
|
||||
Args:
|
||||
@@ -528,7 +528,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_sasl(self, server_msg: list[str]) -> Optional['MSasl']:
|
||||
async def on_sasl(self, server_msg: list[str]) -> Optional['MSasl']:
|
||||
"""Handle SASL coming from a server
|
||||
|
||||
Args:
|
||||
@@ -539,7 +539,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_sasl_authentication_process(self, sasl_model: 'MSasl') -> bool:
|
||||
async def on_sasl_authentication_process(self, sasl_model: 'MSasl') -> bool:
|
||||
"""Finalize sasl authentication
|
||||
|
||||
Args:
|
||||
@@ -550,7 +550,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_md(self, server_msg: list[str]) -> None:
|
||||
async def on_md(self, server_msg: list[str]) -> None:
|
||||
"""Handle MD responses
|
||||
[':001', 'MD', 'client', '001MYIZ03', 'certfp', ':d1235648...']
|
||||
Args:
|
||||
@@ -558,7 +558,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_kick(self, server_msg: list[str]) -> None:
|
||||
async def on_kick(self, server_msg: list[str]) -> None:
|
||||
"""When a user is kicked out from a channel
|
||||
|
||||
Eg. ['@unrealircd.org...', ':001', 'KICK', '#jsonrpc', '001ELW13T', ':Kicked', 'from', 'JSONRPC', 'User']
|
||||
@@ -567,7 +567,7 @@ class IProtocol(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def on_sethost(self, server_msg: list[str]) -> None:
|
||||
async def on_sethost(self, server_msg: list[str]) -> None:
|
||||
"""On SETHOST command
|
||||
>>> [':001DN7305', 'SETHOST', ':netadmin.example.org']
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
return None
|
||||
|
||||
def send2socket(self, message: str, print_log: bool = True) -> None:
|
||||
async def send2socket(self, message: str, print_log: bool = True) -> None:
|
||||
"""Envoit les commandes à envoyer au serveur.
|
||||
|
||||
Args:
|
||||
@@ -108,16 +108,19 @@ class Unrealircd6(IProtocol):
|
||||
"""
|
||||
try:
|
||||
with self._Base.lock:
|
||||
self._Irc.IrcSocket.send(f"{message}\r\n".encode(self._Config.SERVEUR_CHARSET[0]))
|
||||
self._Irc.writer.write(f"{message}\r\n".encode(self._Config.SERVEUR_CHARSET[0]))
|
||||
await self._Irc.writer.drain()
|
||||
if print_log:
|
||||
self._Logs.debug(f'<< {message}')
|
||||
|
||||
except UnicodeDecodeError as ude:
|
||||
self._Logs.error(f'Decode Error try iso-8859-1 - {ude} - {message}')
|
||||
self._Irc.IrcSocket.send(f"{message}\r\n".encode(self._Config.SERVEUR_CHARSET[1],'replace'))
|
||||
self._Irc.writer.write(f"{message}\r\n".encode(self._Config.SERVEUR_CHARSET[1],'replace'))
|
||||
await self._Irc.writer.drain()
|
||||
except UnicodeEncodeError as uee:
|
||||
self._Logs.error(f'Encode Error try iso-8859-1 - {uee} - {message}')
|
||||
self._Irc.IrcSocket.send(f"{message}\r\n".encode(self._Config.SERVEUR_CHARSET[1],'replace'))
|
||||
self._Irc.writer.write(f"{message}\r\n".encode(self._Config.SERVEUR_CHARSET[1],'replace'))
|
||||
await self._Irc.writer.drain()
|
||||
except AssertionError as ae:
|
||||
self._Logs.warning(f'Assertion Error {ae} - message: {message}')
|
||||
except SSLEOFError as soe:
|
||||
@@ -129,7 +132,7 @@ class Unrealircd6(IProtocol):
|
||||
except AttributeError as ae:
|
||||
self._Logs.critical(f"Attribute Error: {ae}")
|
||||
|
||||
def send_priv_msg(self, nick_from: str, msg: str, channel: str = None, nick_to: str = None):
|
||||
async 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
|
||||
could be either channel or nickname not both together
|
||||
Args:
|
||||
@@ -150,18 +153,18 @@ class Unrealircd6(IProtocol):
|
||||
if not channel is None:
|
||||
for i in range(0, len(str(msg)), batch_size):
|
||||
batch = str(msg)[i:i+batch_size]
|
||||
self.send2socket(f":{user_from.uid} PRIVMSG {channel} :{batch}")
|
||||
await self.send2socket(f":{user_from.uid} PRIVMSG {channel} :{batch}")
|
||||
|
||||
if not nick_to is None:
|
||||
for i in range(0, len(str(msg)), batch_size):
|
||||
batch = str(msg)[i:i+batch_size]
|
||||
self.send2socket(f":{nick_from} PRIVMSG {user_to.uid} :{batch}")
|
||||
await self.send2socket(f":{nick_from} PRIVMSG {user_to.uid} :{batch}")
|
||||
|
||||
except Exception as err:
|
||||
self._Logs.error(f"General Error: {err}")
|
||||
self._Logs.error(f"General Error: {nick_from} - {channel} - {nick_to}")
|
||||
|
||||
def send_notice(self, nick_from: str, nick_to: str, msg: str) -> None:
|
||||
async def send_notice(self, nick_from: str, nick_to: str, msg: str) -> None:
|
||||
"""Sending NOTICE by batches
|
||||
|
||||
Args:
|
||||
@@ -180,12 +183,12 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
for i in range(0, len(str(msg)), batch_size):
|
||||
batch = str(msg)[i:i+batch_size]
|
||||
self.send2socket(f":{user_from.uid} NOTICE {user_to.uid} :{batch}")
|
||||
await self.send2socket(f":{user_from.uid} NOTICE {user_to.uid} :{batch}")
|
||||
|
||||
except Exception as err:
|
||||
self._Logs.error(f"General Error: {err}")
|
||||
|
||||
def send_link(self):
|
||||
async def send_link(self):
|
||||
"""Créer le link et envoyer les informations nécessaires pour la
|
||||
connexion au serveur.
|
||||
"""
|
||||
@@ -209,22 +212,22 @@ class Unrealircd6(IProtocol):
|
||||
version = self._Config.CURRENT_VERSION
|
||||
unixtime = self._Utils.get_unixtime()
|
||||
|
||||
self.send2socket(f":{server_id} PASS :{server_password}", print_log=False)
|
||||
self.send2socket(f":{server_id} PROTOCTL SID NOQUIT NICKv2 SJOIN SJ3 NICKIP TKLEXT2 NEXTBANS CLK EXTSWHOIS MLOCK MTAGS")
|
||||
self.send2socket(f":{server_id} PROTOCTL EAUTH={server_link},{protocolversion},,{service_name}-v{version}")
|
||||
self.send2socket(f":{server_id} PROTOCTL SID={server_id}")
|
||||
self.send2socket(f":{server_id} PROTOCTL BOOTED={unixtime}")
|
||||
self.send2socket(f":{server_id} SERVER {server_link} 1 :{service_info}")
|
||||
self.send2socket(f":{server_id} {service_nickname} :Reserved for services")
|
||||
self.send2socket(f":{server_id} UID {service_nickname} 1 {unixtime} {service_username} {service_hostname} {service_id} * {service_smodes} * * fwAAAQ== :{service_realname}")
|
||||
self.send2socket("EOS")
|
||||
self.send_sjoin(service_channel_log)
|
||||
self.send2socket(f":{server_id} TKL + Q * {service_nickname} {service_hostname} 0 {unixtime} :Reserved for services")
|
||||
self.send2socket(f":{service_id} MODE {service_channel_log} {service_cmodes}")
|
||||
await self.send2socket(f":{server_id} PASS :{server_password}", print_log=False)
|
||||
await self.send2socket(f":{server_id} PROTOCTL SID NOQUIT NICKv2 SJOIN SJ3 NICKIP TKLEXT2 NEXTBANS CLK EXTSWHOIS MLOCK MTAGS")
|
||||
await self.send2socket(f":{server_id} PROTOCTL EAUTH={server_link},{protocolversion},,{service_name}-v{version}")
|
||||
await self.send2socket(f":{server_id} PROTOCTL SID={server_id}")
|
||||
await self.send2socket(f":{server_id} PROTOCTL BOOTED={unixtime}")
|
||||
await self.send2socket(f":{server_id} SERVER {server_link} 1 :{service_info}")
|
||||
await self.send2socket(f":{server_id} {service_nickname} :Reserved for services")
|
||||
await self.send2socket(f":{server_id} UID {service_nickname} 1 {unixtime} {service_username} {service_hostname} {service_id} * {service_smodes} * * fwAAAQ== :{service_realname}")
|
||||
await self.send2socket("EOS")
|
||||
await self.send_sjoin(service_channel_log)
|
||||
await self.send2socket(f":{server_id} TKL + Q * {service_nickname} {service_hostname} 0 {unixtime} :Reserved for services")
|
||||
await self.send2socket(f":{service_id} MODE {service_channel_log} {service_cmodes}")
|
||||
|
||||
self._Logs.debug(f'>> {__name__} Link information sent to the server')
|
||||
|
||||
def send_gline(self, nickname: str, hostname: str, set_by: str, expire_timestamp: int, set_at_timestamp: int, reason: str) -> None:
|
||||
async def send_gline(self, nickname: str, hostname: str, set_by: str, expire_timestamp: int, set_at_timestamp: int, reason: str) -> None:
|
||||
"""Send a gline command to the server
|
||||
|
||||
Args:
|
||||
@@ -237,23 +240,23 @@ class Unrealircd6(IProtocol):
|
||||
"""
|
||||
# TKL + G user host set_by expire_timestamp set_at_timestamp :reason
|
||||
|
||||
self.send2socket(f":{self._Config.SERVEUR_ID} TKL + G {nickname} {hostname} {set_by} {expire_timestamp} {set_at_timestamp} :{reason}")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_ID} TKL + G {nickname} {hostname} {set_by} {expire_timestamp} {set_at_timestamp} :{reason}")
|
||||
|
||||
return None
|
||||
|
||||
def send_set_nick(self, newnickname: str) -> None:
|
||||
async def send_set_nick(self, newnickname: str) -> None:
|
||||
"""Change nickname of the server
|
||||
\n This method will also update the User object
|
||||
Args:
|
||||
newnickname (str): New nickname of the server
|
||||
"""
|
||||
self.send2socket(f":{self._Config.SERVICE_NICKNAME} NICK {newnickname}")
|
||||
await self.send2socket(f":{self._Config.SERVICE_NICKNAME} NICK {newnickname}")
|
||||
|
||||
user_obj = self._Irc.User.get_user(self._Config.SERVICE_NICKNAME)
|
||||
self._Irc.User.update_nickname(user_obj.uid, newnickname)
|
||||
return None
|
||||
|
||||
def send_set_mode(self, modes: str, *, nickname: Optional[str] = None, channel_name: Optional[str] = None, params: Optional[str] = None) -> None:
|
||||
async def send_set_mode(self, modes: str, *, nickname: Optional[str] = None, channel_name: Optional[str] = None, params: Optional[str] = None) -> None:
|
||||
"""Set a mode to channel or to a nickname or for a user in a channel
|
||||
|
||||
Args:
|
||||
@@ -273,50 +276,50 @@ class Unrealircd6(IProtocol):
|
||||
if not self._Irc.Channel.is_valid_channel(channel_name):
|
||||
self._Logs.error(f"[MODE ERROR] The channel is not valid: {channel_name}")
|
||||
return None
|
||||
self.send2socket(f":{service_id} MODE {channel_name} {modes} {nickname}")
|
||||
await self.send2socket(f":{service_id} MODE {channel_name} {modes} {nickname}")
|
||||
return None
|
||||
|
||||
if nickname and channel_name is None:
|
||||
self.send2socket(f":{service_id} MODE {nickname} {modes}")
|
||||
await self.send2socket(f":{service_id} MODE {nickname} {modes}")
|
||||
return None
|
||||
|
||||
if nickname is None and channel_name:
|
||||
if not self._Irc.Channel.is_valid_channel(channel_name):
|
||||
self._Logs.error(f"[MODE ERROR] The channel is not valid: {channel_name}")
|
||||
return None
|
||||
self.send2socket(f":{service_id} MODE {channel_name} {modes} {params}")
|
||||
await self.send2socket(f":{service_id} MODE {channel_name} {modes} {params}")
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
def send_squit(self, server_id: str, server_link: str, reason: str) -> None:
|
||||
async def send_squit(self, server_id: str, server_link: str, reason: str) -> None:
|
||||
|
||||
if not reason:
|
||||
reason = 'Service Shutdown'
|
||||
|
||||
self.send2socket(f":{server_id} SQUIT {server_link} :{reason}")
|
||||
await self.send2socket(f":{server_id} SQUIT {server_link} :{reason}")
|
||||
return None
|
||||
|
||||
def send_ungline(self, nickname:str, hostname: str) -> None:
|
||||
async def send_ungline(self, nickname:str, hostname: str) -> None:
|
||||
|
||||
self.send2socket(f":{self._Config.SERVEUR_ID} TKL - G {nickname} {hostname} {self._Config.SERVICE_NICKNAME}")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_ID} TKL - G {nickname} {hostname} {self._Config.SERVICE_NICKNAME}")
|
||||
|
||||
return None
|
||||
|
||||
def send_kline(self, nickname: str, hostname: str, set_by: str, expire_timestamp: int, set_at_timestamp: int, reason: str) -> None:
|
||||
async def send_kline(self, nickname: str, hostname: str, set_by: str, expire_timestamp: int, set_at_timestamp: int, reason: str) -> None:
|
||||
# TKL + k user host set_by expire_timestamp set_at_timestamp :reason
|
||||
|
||||
self.send2socket(f":{self._Config.SERVEUR_ID} TKL + k {nickname} {hostname} {set_by} {expire_timestamp} {set_at_timestamp} :{reason}")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_ID} TKL + k {nickname} {hostname} {set_by} {expire_timestamp} {set_at_timestamp} :{reason}")
|
||||
|
||||
return None
|
||||
|
||||
def send_unkline(self, nickname:str, hostname: str) -> None:
|
||||
async def send_unkline(self, nickname:str, hostname: str) -> None:
|
||||
|
||||
self.send2socket(f":{self._Config.SERVEUR_ID} TKL - K {nickname} {hostname} {self._Config.SERVICE_NICKNAME}")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_ID} TKL - K {nickname} {hostname} {self._Config.SERVICE_NICKNAME}")
|
||||
|
||||
return None
|
||||
|
||||
def send_sjoin(self, channel: str) -> None:
|
||||
async def send_sjoin(self, channel: str) -> None:
|
||||
"""Server will join a channel with pre defined umodes
|
||||
|
||||
Args:
|
||||
@@ -326,14 +329,14 @@ class Unrealircd6(IProtocol):
|
||||
self._Logs.error(f"The channel [{channel}] is not valid")
|
||||
return None
|
||||
|
||||
self.send2socket(f":{self._Config.SERVEUR_ID} SJOIN {self._Utils.get_unixtime()} {channel} {self._Config.SERVICE_UMODES} :{self._Config.SERVICE_ID}")
|
||||
self.send2socket(f":{self._Config.SERVICE_ID} MODE {channel} {self._Config.SERVICE_UMODES} {self._Config.SERVICE_ID}")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_ID} SJOIN {self._Utils.get_unixtime()} {channel} {self._Config.SERVICE_UMODES} :{self._Config.SERVICE_ID}")
|
||||
await self.send2socket(f":{self._Config.SERVICE_ID} MODE {channel} {self._Config.SERVICE_UMODES} {self._Config.SERVICE_ID}")
|
||||
|
||||
# Add defender to the channel uids list
|
||||
self._Irc.Channel.insert(self._Irc.Loader.Definition.MChannel(name=channel, uids=[self._Config.SERVICE_ID]))
|
||||
return None
|
||||
|
||||
def send_sapart(self, nick_to_sapart: str, channel_name: str) -> None:
|
||||
async def send_sapart(self, nick_to_sapart: str, channel_name: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -349,7 +352,7 @@ class Unrealircd6(IProtocol):
|
||||
if user_obj is None or chan_obj is None:
|
||||
return None
|
||||
|
||||
self.send2socket(f":{service_uid} SAPART {user_obj.nickname} {chan_obj.name}")
|
||||
await self.send2socket(f":{service_uid} SAPART {user_obj.nickname} {chan_obj.name}")
|
||||
self._Irc.Channel.delete_user_from_channel(chan_obj.name, user_obj.uid)
|
||||
|
||||
return None
|
||||
@@ -357,7 +360,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def send_sajoin(self, nick_to_sajoin: str, channel_name: str) -> None:
|
||||
async def send_sajoin(self, nick_to_sajoin: str, channel_name: str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -383,18 +386,18 @@ class Unrealircd6(IProtocol):
|
||||
# Create the new channel with the uid
|
||||
new_chan_obj = self._Irc.Loader.Definition.MChannel(name=channel_name, uids=[user_obj.uid])
|
||||
self._Irc.Channel.insert(new_chan_obj)
|
||||
self.send2socket(f":{service_uid} SAJOIN {user_obj.nickname} {new_chan_obj.name}")
|
||||
await self.send2socket(f":{service_uid} SAJOIN {user_obj.nickname} {new_chan_obj.name}")
|
||||
|
||||
else:
|
||||
self._Irc.Channel.add_user_to_a_channel(channel_name=channel_name, uid=user_obj.uid)
|
||||
self.send2socket(f":{service_uid} SAJOIN {user_obj.nickname} {chan_obj.name}")
|
||||
await self.send2socket(f":{service_uid} SAJOIN {user_obj.nickname} {chan_obj.name}")
|
||||
|
||||
return None
|
||||
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def send_svspart(self, nick_to_part: str, channels: list[str], reason: str) -> None:
|
||||
async def send_svspart(self, nick_to_part: str, channels: list[str], reason: str) -> None:
|
||||
user_obj = self._Irc.User.get_user(nick_to_part)
|
||||
|
||||
if user_obj is None:
|
||||
@@ -403,10 +406,10 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
channels_list = ','.join([channel for channel in channels if self._Irc.Channel.is_valid_channel(channel)])
|
||||
service_id = self._Config.SERVICE_ID
|
||||
self.send2socket(f':{service_id} SVSPART {user_obj.nickname} {channels_list} {reason}')
|
||||
await self.send2socket(f':{service_id} SVSPART {user_obj.nickname} {channels_list} {reason}')
|
||||
return None
|
||||
|
||||
def send_svsjoin(self, nick_to_part: str, channels: list[str], keys: list[str]) -> None:
|
||||
async def send_svsjoin(self, nick_to_part: str, channels: list[str], keys: list[str]) -> None:
|
||||
user_obj = self._Irc.User.get_user(nick_to_part)
|
||||
|
||||
if user_obj is None:
|
||||
@@ -416,10 +419,10 @@ class Unrealircd6(IProtocol):
|
||||
channels_list = ','.join([channel for channel in channels if self._Irc.Channel.is_valid_channel(channel)])
|
||||
keys_list = ','.join([key for key in keys])
|
||||
service_id = self._Config.SERVICE_ID
|
||||
self.send2socket(f':{service_id} SVSJOIN {user_obj.nickname} {channels_list} {keys_list}')
|
||||
await self.send2socket(f':{service_id} SVSJOIN {user_obj.nickname} {channels_list} {keys_list}')
|
||||
return None
|
||||
|
||||
def send_svsmode(self, nickname: str, user_mode: str) -> None:
|
||||
async def send_svsmode(self, nickname: str, user_mode: str) -> None:
|
||||
try:
|
||||
user_obj = self._Irc.User.get_user(uidornickname=nickname)
|
||||
service_uid = self._Config.SERVICE_ID
|
||||
@@ -427,7 +430,7 @@ class Unrealircd6(IProtocol):
|
||||
if user_obj is None:
|
||||
return None
|
||||
|
||||
self.send2socket(f':{service_uid} SVSMODE {nickname} {user_mode}')
|
||||
await self.send2socket(f':{service_uid} SVSMODE {nickname} {user_mode}')
|
||||
|
||||
# Update new mode
|
||||
self._Irc.User.update_mode(user_obj.uid, user_mode)
|
||||
@@ -436,7 +439,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def send_svs2mode(self, nickname: str, user_mode: str) -> None:
|
||||
async def send_svs2mode(self, nickname: str, user_mode: str) -> None:
|
||||
try:
|
||||
user_obj = self._Irc.User.get_user(uidornickname=nickname)
|
||||
service_uid = self._Config.SERVICE_ID
|
||||
@@ -444,7 +447,7 @@ class Unrealircd6(IProtocol):
|
||||
if user_obj is None:
|
||||
return None
|
||||
|
||||
self.send2socket(f':{service_uid} SVS2MODE {nickname} {user_mode}')
|
||||
await self.send2socket(f':{service_uid} SVS2MODE {nickname} {user_mode}')
|
||||
|
||||
# Update new mode
|
||||
self._Irc.User.update_mode(user_obj.uid, user_mode)
|
||||
@@ -453,7 +456,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def send_svslogin(self, client_uid: str, user_account: str) -> None:
|
||||
async def send_svslogin(self, client_uid: str, user_account: str) -> None:
|
||||
"""Log a client into his account.
|
||||
|
||||
Args:
|
||||
@@ -461,11 +464,11 @@ class Unrealircd6(IProtocol):
|
||||
user_account (str): The account of the user
|
||||
"""
|
||||
try:
|
||||
self.send2socket(f":{self._Irc.Config.SERVEUR_LINK} SVSLOGIN {self._Settings.MAIN_SERVER_HOSTNAME} {client_uid} {user_account}")
|
||||
await self.send2socket(f":{self._Irc.Config.SERVEUR_LINK} SVSLOGIN {self._Settings.MAIN_SERVER_HOSTNAME} {client_uid} {user_account}")
|
||||
except Exception as err:
|
||||
self._Logs.error(f'General Error: {err}')
|
||||
|
||||
def send_svslogout(self, client_obj: 'MClient') -> None:
|
||||
async def send_svslogout(self, client_obj: 'MClient') -> None:
|
||||
"""Logout a client from his account
|
||||
|
||||
Args:
|
||||
@@ -474,13 +477,13 @@ class Unrealircd6(IProtocol):
|
||||
try:
|
||||
c_uid = client_obj.uid
|
||||
c_nickname = client_obj.nickname
|
||||
self.send2socket(f":{self._Irc.Config.SERVEUR_LINK} SVSLOGIN {self._Settings.MAIN_SERVER_HOSTNAME} {c_uid} 0")
|
||||
await self.send2socket(f":{self._Irc.Config.SERVEUR_LINK} SVSLOGIN {self._Settings.MAIN_SERVER_HOSTNAME} {c_uid} 0")
|
||||
self.send_svs2mode(c_nickname, '-r')
|
||||
|
||||
except Exception as err:
|
||||
self._Logs.error(f'General Error: {err}')
|
||||
|
||||
def send_quit(self, uid: str, reason: str, print_log: bool = True) -> None:
|
||||
async def send_quit(self, uid: str, reason: str, print_log: bool = True) -> None:
|
||||
"""Send quit message
|
||||
- Delete uid from User object
|
||||
- Delete uid from Reputation object
|
||||
@@ -494,7 +497,7 @@ class Unrealircd6(IProtocol):
|
||||
reputation_obj = self._Irc.Reputation.get_reputation(uidornickname=uid)
|
||||
|
||||
if not user_obj is None:
|
||||
self.send2socket(f":{user_obj.uid} QUIT :{reason}", print_log=print_log)
|
||||
await self.send2socket(f":{user_obj.uid} QUIT :{reason}", print_log=print_log)
|
||||
self._Irc.User.delete(user_obj.uid)
|
||||
|
||||
if not reputation_obj is None:
|
||||
@@ -505,7 +508,7 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
return None
|
||||
|
||||
def send_uid(self, nickname:str, username: str, hostname: str, uid:str, umodes: str,
|
||||
async 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
|
||||
- Insert User to User Object
|
||||
@@ -537,14 +540,14 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
uid_msg = f":{self._Config.SERVEUR_ID} UID {nickname} 1 {unixtime} {username} {hostname} {uid} * {umodes} {vhost} * {encoded_ip} :{realname}"
|
||||
|
||||
self.send2socket(uid_msg, print_log=print_log)
|
||||
await self.send2socket(uid_msg, print_log=print_log)
|
||||
|
||||
return None
|
||||
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def send_join_chan(self, uidornickname: str, channel: str, password: str = None, print_log: bool = True) -> None:
|
||||
async def send_join_chan(self, uidornickname: str, channel: str, password: str = None, print_log: bool = True) -> None:
|
||||
"""Joining a channel
|
||||
|
||||
Args:
|
||||
@@ -564,10 +567,10 @@ class Unrealircd6(IProtocol):
|
||||
self._Logs.error(f"The channel [{channel}] is not valid")
|
||||
return None
|
||||
|
||||
self.send2socket(f":{user_obj.uid} JOIN {channel} {pwd_channel}", print_log=print_log)
|
||||
await self.send2socket(f":{user_obj.uid} JOIN {channel} {pwd_channel}", print_log=print_log)
|
||||
|
||||
if uidornickname == self._Config.SERVICE_NICKNAME or uidornickname == self._Config.SERVICE_ID:
|
||||
self.send2socket(f":{self._Config.SERVICE_ID} MODE {channel} {self._Config.SERVICE_UMODES} {self._Config.SERVICE_ID}")
|
||||
await self.send2socket(f":{self._Config.SERVICE_ID} MODE {channel} {self._Config.SERVICE_UMODES} {self._Config.SERVICE_ID}")
|
||||
|
||||
# Add defender to the channel uids list
|
||||
self._Irc.Channel.insert(self._Irc.Loader.Definition.MChannel(name=channel, uids=[user_obj.uid]))
|
||||
@@ -581,11 +584,11 @@ class Unrealircd6(IProtocol):
|
||||
db_result = db_query.fetchone()
|
||||
if db_result is not None:
|
||||
id_cmd_automode, mode = db_result
|
||||
self.send2socket(f":{self._Config.SERVICE_ID} MODE {channel} {mode} {user_obj.nickname}")
|
||||
await self.send2socket(f":{self._Config.SERVICE_ID} MODE {channel} {mode} {user_obj.nickname}")
|
||||
|
||||
return None
|
||||
|
||||
def send_part_chan(self, uidornickname:str, channel: str, print_log: bool = True) -> None:
|
||||
async def send_part_chan(self, uidornickname:str, channel: str, print_log: bool = True) -> None:
|
||||
"""Part from a channel
|
||||
|
||||
Args:
|
||||
@@ -604,25 +607,25 @@ class Unrealircd6(IProtocol):
|
||||
self._Logs.error(f"The channel [{channel}] is not valid")
|
||||
return None
|
||||
|
||||
self.send2socket(f":{u.uid} PART {channel}", print_log=print_log)
|
||||
await self.send2socket(f":{u.uid} PART {channel}", print_log=print_log)
|
||||
|
||||
# Add defender to the channel uids list
|
||||
self._Irc.Channel.delete_user_from_channel(channel, u.uid)
|
||||
return None
|
||||
|
||||
def send_mode_chan(self, channel_name: str, channel_mode: str) -> None:
|
||||
async def send_mode_chan(self, channel_name: str, channel_mode: str) -> None:
|
||||
|
||||
channel = self._Irc.Channel.is_valid_channel(channel_name)
|
||||
if not channel:
|
||||
self._Logs.error(f'The channel [{channel_name}] is not correct')
|
||||
return None
|
||||
|
||||
self.send2socket(f":{self._Config.SERVICE_NICKNAME} MODE {channel_name} {channel_mode}")
|
||||
await self.send2socket(f":{self._Config.SERVICE_NICKNAME} MODE {channel_name} {channel_mode}")
|
||||
return None
|
||||
|
||||
def send_raw(self, raw_command: str) -> None:
|
||||
async def send_raw(self, raw_command: str) -> None:
|
||||
|
||||
self.send2socket(f":{self._Config.SERVICE_NICKNAME} {raw_command}")
|
||||
await self.send2socket(f":{self._Config.SERVICE_NICKNAME} {raw_command}")
|
||||
|
||||
return None
|
||||
|
||||
@@ -713,7 +716,7 @@ class Unrealircd6(IProtocol):
|
||||
# HANDLE EVENTS #
|
||||
#####################
|
||||
|
||||
def on_svs2mode(self, server_msg: list[str]) -> None:
|
||||
async def on_svs2mode(self, server_msg: list[str]) -> None:
|
||||
"""Handle svs2mode coming from a server
|
||||
>>> [':00BAAAAAG', 'SVS2MODE', '001U01R03', '-r']
|
||||
|
||||
@@ -740,7 +743,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_mode(self, server_msg: list[str]) -> None:
|
||||
async def on_mode(self, server_msg: list[str]) -> None:
|
||||
"""Handle mode coming from a server
|
||||
|
||||
Args:
|
||||
@@ -751,7 +754,7 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
return None
|
||||
|
||||
def on_umode2(self, server_msg: list[str]) -> None:
|
||||
async def on_umode2(self, server_msg: list[str]) -> None:
|
||||
"""Handle umode2 coming from a server
|
||||
>>> [':adator_', 'UMODE2', '-i']
|
||||
|
||||
@@ -778,7 +781,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_quit(self, server_msg: list[str]) -> None:
|
||||
async def on_quit(self, server_msg: list[str]) -> None:
|
||||
"""Handle quit coming from a server
|
||||
|
||||
Args:
|
||||
@@ -802,7 +805,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_squit(self, server_msg: list[str]) -> None:
|
||||
async def on_squit(self, server_msg: list[str]) -> None:
|
||||
"""Handle squit coming from a server
|
||||
|
||||
Args:
|
||||
@@ -824,7 +827,7 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
return None
|
||||
|
||||
def on_protoctl(self, server_msg: list[str]) -> None:
|
||||
async def on_protoctl(self, server_msg: list[str]) -> None:
|
||||
"""Handle protoctl coming from a server
|
||||
|
||||
Args:
|
||||
@@ -861,7 +864,7 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
return None
|
||||
|
||||
def on_nick(self, server_msg: list[str]) -> None:
|
||||
async def on_nick(self, server_msg: list[str]) -> None:
|
||||
"""Handle nick coming from a server
|
||||
new nickname
|
||||
|
||||
@@ -886,7 +889,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_sjoin(self, server_msg: list[str]) -> None:
|
||||
async def on_sjoin(self, server_msg: list[str]) -> None:
|
||||
"""Handle sjoin coming from a server
|
||||
|
||||
Args:
|
||||
@@ -939,7 +942,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_part(self, server_msg: list[str]) -> None:
|
||||
async def on_part(self, server_msg: list[str]) -> None:
|
||||
"""Handle part coming from a server
|
||||
|
||||
Args:
|
||||
@@ -957,7 +960,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_eos(self, server_msg: list[str]) -> None:
|
||||
async def on_eos(self, server_msg: list[str]) -> None:
|
||||
"""Handle EOS coming from a server
|
||||
|
||||
Args:
|
||||
@@ -998,17 +1001,17 @@ class Unrealircd6(IProtocol):
|
||||
self._Logs.info(f"# VERSION : {version} ")
|
||||
self._Logs.info(f"################################################")
|
||||
|
||||
self.send_sjoin(self._Config.SERVICE_CHANLOG)
|
||||
await self.send_sjoin(self._Config.SERVICE_CHANLOG)
|
||||
|
||||
if self._Base.check_for_new_version(False):
|
||||
self.send_priv_msg(
|
||||
await self.send_priv_msg(
|
||||
nick_from=self._Config.SERVICE_NICKNAME,
|
||||
msg=f" New Version available {version}",
|
||||
channel=self._Config.SERVICE_CHANLOG
|
||||
)
|
||||
|
||||
# Initialisation terminé aprés le premier PING
|
||||
self.send_priv_msg(
|
||||
await self.send_priv_msg(
|
||||
nick_from=self._Config.SERVICE_NICKNAME,
|
||||
msg=tr("[ %sINFORMATION%s ] >> %s is ready!", self._Config.COLORS.green, self._Config.COLORS.nogc, self._Config.SERVICE_NICKNAME),
|
||||
channel=self._Config.SERVICE_CHANLOG
|
||||
@@ -1020,10 +1023,10 @@ class Unrealircd6(IProtocol):
|
||||
module.class_instance.cmd(server_msg_copy)
|
||||
|
||||
# Join saved channels & load existing modules
|
||||
self._Irc.join_saved_channels()
|
||||
self._Irc.ModuleUtils.db_load_all_existing_modules(self._Irc)
|
||||
await self._Irc.join_saved_channels()
|
||||
await self._Irc.ModuleUtils.db_load_all_existing_modules(self._Irc)
|
||||
|
||||
self.send2socket(f":{self._Config.SERVEUR_ID} SMOD :L:Defender:1.0.0 :L:Command:1.0.0")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_ID} SMOD :L:Defender:1.0.0 :L:Command:1.0.0")
|
||||
|
||||
return None
|
||||
except IndexError as ie:
|
||||
@@ -1033,7 +1036,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_reputation(self, server_msg: list[str]) -> None:
|
||||
async def on_reputation(self, server_msg: list[str]) -> None:
|
||||
"""Handle REPUTATION coming from a server
|
||||
|
||||
Args:
|
||||
@@ -1064,7 +1067,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_uid(self, server_msg: list[str]) -> None:
|
||||
async def on_uid(self, server_msg: list[str]) -> None:
|
||||
"""Handle uid message coming from the server
|
||||
|
||||
Args:
|
||||
@@ -1142,15 +1145,15 @@ class Unrealircd6(IProtocol):
|
||||
if sasl_obj:
|
||||
if sasl_obj.auth_success:
|
||||
self._Irc.insert_db_admin(sasl_obj.client_uid, sasl_obj.username, sasl_obj.level, sasl_obj.language)
|
||||
self.send_priv_msg(nick_from=dnickname,
|
||||
await self.send_priv_msg(nick_from=dnickname,
|
||||
msg=tr("[ %sSASL AUTH%s ] - %s (%s) is now connected successfuly to %s", green, nogc, nickname, sasl_obj.username, dnickname),
|
||||
channel=dchanlog)
|
||||
self.send_notice(nick_from=dnickname, nick_to=nickname, msg=tr("Successfuly connected to %s", dnickname))
|
||||
await self.send_notice(nick_from=dnickname, nick_to=nickname, msg=tr("Successfuly connected to %s", dnickname))
|
||||
else:
|
||||
self.send_priv_msg(nick_from=dnickname,
|
||||
await self.send_priv_msg(nick_from=dnickname,
|
||||
msg=tr("[ %sSASL AUTH%s ] - %s provided a wrong password for this username %s", red, nogc, nickname, sasl_obj.username),
|
||||
channel=dchanlog)
|
||||
self.send_notice(nick_from=dnickname, nick_to=nickname, msg=tr("Wrong password!"))
|
||||
await self.send_notice(nick_from=dnickname, nick_to=nickname, msg=tr("Wrong password!"))
|
||||
|
||||
# Delete sasl object!
|
||||
self._Irc.Sasl.delete_sasl_client(uid)
|
||||
@@ -1160,10 +1163,10 @@ class Unrealircd6(IProtocol):
|
||||
if self._Irc.Admin.db_auth_admin_via_fingerprint(fingerprint, uid):
|
||||
admin = self._Irc.Admin.get_admin(uid)
|
||||
account = admin.account if admin else ''
|
||||
self.send_priv_msg(nick_from=dnickname,
|
||||
await self.send_priv_msg(nick_from=dnickname,
|
||||
msg=tr("[ %sFINGERPRINT AUTH%s ] - %s (%s) is now connected successfuly to %s", green, nogc, nickname, account, dnickname),
|
||||
channel=dchanlog)
|
||||
self.send_notice(nick_from=dnickname, nick_to=nickname, msg=tr("Successfuly connected to %s", dnickname))
|
||||
await self.send_notice(nick_from=dnickname, nick_to=nickname, msg=tr("Successfuly connected to %s", dnickname))
|
||||
|
||||
return None
|
||||
except IndexError as ie:
|
||||
@@ -1171,7 +1174,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_privmsg(self, server_msg: list[str]) -> None:
|
||||
async def on_privmsg(self, server_msg: list[str]) -> None:
|
||||
"""Handle PRIVMSG message coming from the server
|
||||
|
||||
Args:
|
||||
@@ -1197,7 +1200,7 @@ class Unrealircd6(IProtocol):
|
||||
arg.remove(f':{self._Config.SERVICE_PREFIX}')
|
||||
if not self._Irc.Commands.is_command_exist(arg[0]):
|
||||
self._Logs.debug(f"This command {arg[0]} is not available")
|
||||
self.send_notice(
|
||||
await self.send_notice(
|
||||
nick_from=self._Config.SERVICE_NICKNAME,
|
||||
nick_to=user_trigger,
|
||||
msg=f"This command [{self._Config.COLORS.bold}{arg[0]}{self._Config.COLORS.bold}] is not available"
|
||||
@@ -1208,7 +1211,7 @@ class Unrealircd6(IProtocol):
|
||||
self._Base.log_cmd(user_trigger, cmd_to_send)
|
||||
|
||||
fromchannel = str(cmd[2]).lower() if self._Irc.Channel.is_valid_channel(cmd[2]) else None
|
||||
self._Irc.hcmds(user_trigger, fromchannel, arg, cmd)
|
||||
await self._Irc.hcmds(user_trigger, fromchannel, arg, cmd)
|
||||
|
||||
if cmd[2] == self._Config.SERVICE_ID:
|
||||
pattern = fr'^:.*?:(.*)$'
|
||||
@@ -1221,35 +1224,31 @@ class Unrealircd6(IProtocol):
|
||||
|
||||
# Réponse a un CTCP VERSION
|
||||
if arg[0] == '\x01VERSION\x01':
|
||||
self.on_version(srv_msg)
|
||||
await self.on_version(srv_msg)
|
||||
return None
|
||||
|
||||
# Réponse a un TIME
|
||||
if arg[0] == '\x01TIME\x01':
|
||||
self.on_time(srv_msg)
|
||||
await self.on_time(srv_msg)
|
||||
return None
|
||||
|
||||
# Réponse a un PING
|
||||
if arg[0] == '\x01PING':
|
||||
self.on_ping(srv_msg)
|
||||
await self.on_ping(srv_msg)
|
||||
return None
|
||||
|
||||
if not self._Irc.Commands.is_command_exist(arg[0]):
|
||||
self._Logs.debug(f"This command {arg[0]} sent by {user_trigger} is not available")
|
||||
return None
|
||||
|
||||
# if not arg[0].lower() in self._Irc.module_commands_list:
|
||||
# self._Logs.debug(f"This command {arg[0]} sent by {user_trigger} is not available")
|
||||
# return False
|
||||
|
||||
cmd_to_send = convert_to_string.replace(':','')
|
||||
self._Base.log_cmd(user_trigger, cmd_to_send)
|
||||
|
||||
fromchannel = None
|
||||
|
||||
if len(arg) >= 2:
|
||||
fromchannel = str(arg[1]).lower() if self._Irc.Channel.is_valid_channel(arg[1]) else None
|
||||
|
||||
self._Irc.hcmds(user_trigger, fromchannel, arg, cmd)
|
||||
await self._Irc.hcmds(user_trigger, fromchannel, arg, cmd)
|
||||
return None
|
||||
|
||||
except KeyError as ke:
|
||||
@@ -1259,7 +1258,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"General Error: {err} - {srv_msg}" , exc_info=True)
|
||||
|
||||
def on_server_ping(self, server_msg: list[str]) -> None:
|
||||
async def on_server_ping(self, server_msg: list[str]) -> None:
|
||||
"""Send a PONG message to the server
|
||||
|
||||
Args:
|
||||
@@ -1267,14 +1266,13 @@ class Unrealircd6(IProtocol):
|
||||
"""
|
||||
try:
|
||||
scopy = server_msg.copy()
|
||||
pong = str(scopy[1]).replace(':','')
|
||||
self.send2socket(f"PONG :{pong}", print_log=False)
|
||||
await self.send2socket(' '.join(scopy).replace('PING', 'PONG'), print_log=True)
|
||||
|
||||
return None
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_server(self, server_msg: list[str]) -> None:
|
||||
async def on_server(self, server_msg: list[str]) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
@@ -1287,7 +1285,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f'General Error: {err}')
|
||||
|
||||
def on_version(self, server_msg: list[str]) -> None:
|
||||
async def on_version(self, server_msg: list[str]) -> None:
|
||||
"""Sending Server Version to the server
|
||||
|
||||
Args:
|
||||
@@ -1305,13 +1303,13 @@ class Unrealircd6(IProtocol):
|
||||
return None
|
||||
|
||||
if arg == '\x01VERSION\x01':
|
||||
self.send2socket(f':{dnickname} NOTICE {nickname} :\x01VERSION Service {self._Config.SERVICE_NICKNAME} V{self._Config.CURRENT_VERSION}\x01')
|
||||
await self.send2socket(f':{dnickname} NOTICE {nickname} :\x01VERSION Service {self._Config.SERVICE_NICKNAME} V{self._Config.CURRENT_VERSION}\x01')
|
||||
|
||||
return None
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_time(self, server_msg: list[str]) -> None:
|
||||
async def on_time(self, server_msg: list[str]) -> None:
|
||||
"""Sending TIME answer to a requestor
|
||||
|
||||
Args:
|
||||
@@ -1330,13 +1328,13 @@ class Unrealircd6(IProtocol):
|
||||
return None
|
||||
|
||||
if arg == '\x01TIME\x01':
|
||||
self.send2socket(f':{dnickname} NOTICE {nickname} :\x01TIME {current_datetime}\x01')
|
||||
await self.send2socket(f':{dnickname} NOTICE {nickname} :\x01TIME {current_datetime}\x01')
|
||||
|
||||
return None
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_ping(self, server_msg: list[str]) -> None:
|
||||
async def on_ping(self, server_msg: list[str]) -> None:
|
||||
"""Sending a PING answer to requestor
|
||||
|
||||
Args:
|
||||
@@ -1360,7 +1358,7 @@ class Unrealircd6(IProtocol):
|
||||
ping_response = current_unixtime - recieved_unixtime
|
||||
|
||||
# self._Irc.send2socket(f':{dnickname} NOTICE {nickname} :\x01PING {ping_response} secs\x01')
|
||||
self.send_notice(
|
||||
await self.send_notice(
|
||||
nick_from=dnickname,
|
||||
nick_to=nickname,
|
||||
msg=f"\x01PING {ping_response} secs\x01"
|
||||
@@ -1371,7 +1369,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_version_msg(self, server_msg: list[str]) -> None:
|
||||
async def on_version_msg(self, server_msg: list[str]) -> None:
|
||||
"""Handle version coming from the server
|
||||
\n ex. /version Defender
|
||||
Args:
|
||||
@@ -1389,21 +1387,21 @@ class Unrealircd6(IProtocol):
|
||||
return None
|
||||
|
||||
response_351 = f"{self._Config.SERVICE_NAME.capitalize()}-{self._Config.CURRENT_VERSION} {self._Config.SERVICE_HOST} {self.name}"
|
||||
self.send2socket(f':{self._Config.SERVICE_HOST} 351 {u.nickname} {response_351}')
|
||||
await self.send2socket(f':{self._Config.SERVICE_HOST} 351 {u.nickname} {response_351}')
|
||||
|
||||
modules = self._Irc.ModuleUtils.get_all_available_modules()
|
||||
response_005 = ' | '.join(modules)
|
||||
self.send2socket(f':{self._Config.SERVICE_HOST} 005 {u.nickname} {response_005} are supported by this server')
|
||||
await self.send2socket(f':{self._Config.SERVICE_HOST} 005 {u.nickname} {response_005} are supported by this server')
|
||||
|
||||
response_005 = ''.join(self._Settings.PROTOCTL_USER_MODES)
|
||||
self.send2socket(f":{self._Config.SERVICE_HOST} 005 {u.nickname} {response_005} are supported by this server")
|
||||
await self.send2socket(f":{self._Config.SERVICE_HOST} 005 {u.nickname} {response_005} are supported by this server")
|
||||
|
||||
return None
|
||||
|
||||
except Exception as err:
|
||||
self._Logs.error(f"{__name__} - General Error: {err}")
|
||||
|
||||
def on_smod(self, server_msg: list[str]) -> None:
|
||||
async def on_smod(self, server_msg: list[str]) -> None:
|
||||
"""Handle SMOD message coming from the server
|
||||
|
||||
Args:
|
||||
@@ -1422,7 +1420,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as err:
|
||||
self._Logs.error(f'General Error: {err}')
|
||||
|
||||
def on_sasl(self, server_msg: list[str]) -> Optional['MSasl']:
|
||||
async def on_sasl(self, server_msg: list[str]) -> Optional['MSasl']:
|
||||
"""Handle SASL coming from a server
|
||||
|
||||
Args:
|
||||
@@ -1465,13 +1463,13 @@ class Unrealircd6(IProtocol):
|
||||
sasl_obj.mechanisme = str(scopy[5])
|
||||
|
||||
if sasl_obj.mechanisme == "PLAIN":
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {sasl_obj.client_uid} C +")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {sasl_obj.client_uid} C +")
|
||||
elif sasl_obj.mechanisme == "EXTERNAL":
|
||||
if str(scopy[5]) == "+":
|
||||
return None
|
||||
|
||||
sasl_obj.fingerprint = str(scopy[6])
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {sasl_obj.client_uid} C +")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {sasl_obj.client_uid} C +")
|
||||
|
||||
self.on_sasl_authentication_process(sasl_obj)
|
||||
return sasl_obj
|
||||
@@ -1486,18 +1484,18 @@ class Unrealircd6(IProtocol):
|
||||
sasl_obj.username = username
|
||||
sasl_obj.password = password
|
||||
|
||||
self.on_sasl_authentication_process(sasl_obj)
|
||||
await self.on_sasl_authentication_process(sasl_obj)
|
||||
return sasl_obj
|
||||
elif sasl_obj.mechanisme == "EXTERNAL":
|
||||
sasl_obj.message_type = sasl_message_type
|
||||
|
||||
self.on_sasl_authentication_process(sasl_obj)
|
||||
await self.on_sasl_authentication_process(sasl_obj)
|
||||
return sasl_obj
|
||||
|
||||
except Exception as err:
|
||||
self._Logs.error(f'General Error: {err}', exc_info=True)
|
||||
|
||||
def on_sasl_authentication_process(self, sasl_model: 'MSasl') -> None:
|
||||
async def on_sasl_authentication_process(self, sasl_model: 'MSasl') -> None:
|
||||
s = sasl_model
|
||||
if sasl_model:
|
||||
def db_get_admin_info(*, username: Optional[str] = None, password: Optional[str] = None, fingerprint: Optional[str] = None) -> Optional[dict[str, Any]]:
|
||||
@@ -1522,11 +1520,11 @@ class Unrealircd6(IProtocol):
|
||||
s.auth_success = True
|
||||
s.level = admin_info.get('level', 0)
|
||||
s.language = admin_info.get('language', 'EN')
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {s.client_uid} D S")
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} 903 {s.username} :SASL authentication successful")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {s.client_uid} D S")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} 903 {s.username} :SASL authentication successful")
|
||||
else:
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {s.client_uid} D F")
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} 904 {s.username} :SASL authentication failed")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {s.client_uid} D F")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} 904 {s.username} :SASL authentication failed")
|
||||
|
||||
elif s.message_type == 'S' and s.mechanisme == 'EXTERNAL':
|
||||
# Connection using fingerprints
|
||||
@@ -1537,14 +1535,14 @@ class Unrealircd6(IProtocol):
|
||||
s.level = admin_info.get('level', 0)
|
||||
s.username = admin_info.get('user', None)
|
||||
s.language = admin_info.get('language', 'EN')
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {s.client_uid} D S")
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} 903 {s.username} :SASL authentication successful")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {s.client_uid} D S")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} 903 {s.username} :SASL authentication successful")
|
||||
else:
|
||||
# "904 <nick> :SASL authentication failed"
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {s.client_uid} D F")
|
||||
self.send2socket(f":{self._Config.SERVEUR_LINK} 904 {s.username} :SASL authentication failed")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} SASL {self._Settings.MAIN_SERVER_HOSTNAME} {s.client_uid} D F")
|
||||
await self.send2socket(f":{self._Config.SERVEUR_LINK} 904 {s.username} :SASL authentication failed")
|
||||
|
||||
def on_md(self, server_msg: list[str]) -> None:
|
||||
async def on_md(self, server_msg: list[str]) -> None:
|
||||
"""Handle MD responses
|
||||
[':001', 'MD', 'client', '001MYIZ03', 'certfp', ':d1235648...']
|
||||
Args:
|
||||
@@ -1573,7 +1571,7 @@ class Unrealircd6(IProtocol):
|
||||
except Exception as e:
|
||||
self._Logs.error(f"General Error: {e}")
|
||||
|
||||
def on_kick(self, server_msg: list[str]) -> None:
|
||||
async def on_kick(self, server_msg: list[str]) -> None:
|
||||
"""When a user is kicked out from a channel
|
||||
|
||||
['@unrealircd.org/issued-by=RPC:admin-for-test@...', ':001', 'KICK', '#jsonrpc', '001ELW13T', ':Kicked', 'from', 'JSONRPC', 'User']
|
||||
@@ -1588,7 +1586,7 @@ class Unrealircd6(IProtocol):
|
||||
self._Irc.Channel.delete_user_from_channel(channel, uid)
|
||||
return None
|
||||
|
||||
def on_sethost(self, server_msg: list[str]) -> None:
|
||||
async def on_sethost(self, server_msg: list[str]) -> None:
|
||||
"""On SETHOST command
|
||||
>>> [':001DN7305', 'SETHOST', ':netadmin.example.org']
|
||||
|
||||
|
||||
88
core/irc.py
88
core/irc.py
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import sys
|
||||
import socket
|
||||
import ssl
|
||||
@@ -26,6 +27,8 @@ class Irc:
|
||||
|
||||
def __init__(self, loader: 'Loader'):
|
||||
|
||||
self.signal: bool = True
|
||||
|
||||
# Loader class
|
||||
self.Loader = loader
|
||||
|
||||
@@ -132,8 +135,34 @@ class Irc:
|
||||
# Define the IrcSocket object
|
||||
self.IrcSocket: Optional[Union[socket.socket, SSLSocket]] = None
|
||||
|
||||
self.reader: Optional[asyncio.StreamReader] = None
|
||||
self.writer: Optional[asyncio.StreamWriter] = None
|
||||
|
||||
self.Base.create_thread(func=self.heartbeat, func_args=(self.beat, ))
|
||||
|
||||
async def connect(self):
|
||||
|
||||
if self.Config.SERVEUR_SSL:
|
||||
self.reader, self.writer = await asyncio.open_connection(self.Config.SERVEUR_IP, self.Config.SERVEUR_PORT, ssl=self.Utils.get_ssl_context())
|
||||
else:
|
||||
self.reader, self.writer = await asyncio.open_connection(self.Config.SERVEUR_IP, self.Config.SERVEUR_PORT)
|
||||
|
||||
self.init_service_user()
|
||||
self.Protocol: 'IProtocol' = self.Loader.PFactory.get()
|
||||
self.Protocol.register_command()
|
||||
await self.Protocol.send_link()
|
||||
|
||||
|
||||
async def listen(self):
|
||||
|
||||
while self.signal:
|
||||
data = await self.reader.readuntil(b'\r\n')
|
||||
await self.send_response(data.splitlines())
|
||||
|
||||
async def run(self):
|
||||
await self.connect()
|
||||
await self.listen()
|
||||
|
||||
##############################################
|
||||
# CONNEXION IRC #
|
||||
##############################################
|
||||
@@ -232,7 +261,7 @@ class Irc:
|
||||
except Exception as e:
|
||||
self.Logs.critical(f"General Error: {e}", exc_info=True)
|
||||
|
||||
def join_saved_channels(self) -> None:
|
||||
async def join_saved_channels(self) -> None:
|
||||
"""## Joining saved channels"""
|
||||
exec_query = self.Base.db_execute_query(f'SELECT distinct channel_name FROM {self.Config.TABLE_CHANNEL}')
|
||||
result_query = exec_query.fetchall()
|
||||
@@ -240,25 +269,25 @@ class Irc:
|
||||
if result_query:
|
||||
for chan_name in result_query:
|
||||
chan = chan_name[0]
|
||||
self.Protocol.send_sjoin(channel=chan)
|
||||
await self.Protocol.send_sjoin(channel=chan)
|
||||
|
||||
def send_response(self, responses:list[bytes]) -> None:
|
||||
async def send_response(self, responses:list[bytes]) -> None:
|
||||
try:
|
||||
for data in responses:
|
||||
response = data.decode(self.CHARSET[0]).split()
|
||||
self.cmd(response)
|
||||
await self.cmd(response)
|
||||
|
||||
except UnicodeEncodeError as ue:
|
||||
for data in responses:
|
||||
response = data.decode(self.CHARSET[1],'replace').split()
|
||||
self.cmd(response)
|
||||
await self.cmd(response)
|
||||
self.Logs.error(f'UnicodeEncodeError: {ue}')
|
||||
self.Logs.error(response)
|
||||
|
||||
except UnicodeDecodeError as ud:
|
||||
for data in responses:
|
||||
response = data.decode(self.CHARSET[1],'replace').split()
|
||||
self.cmd(response)
|
||||
await self.cmd(response)
|
||||
self.Logs.error(f'UnicodeDecodeError: {ud}')
|
||||
self.Logs.error(response)
|
||||
|
||||
@@ -287,7 +316,7 @@ class Irc:
|
||||
|
||||
return None
|
||||
|
||||
def generate_help_menu(self, nickname: str, module: Optional[str] = None) -> None:
|
||||
async def generate_help_menu(self, nickname: str, module: Optional[str] = None) -> None:
|
||||
|
||||
# Check if the nickname is an admin
|
||||
p = self.Protocol
|
||||
@@ -300,14 +329,14 @@ class Irc:
|
||||
if admin_obj is not None:
|
||||
current_level = admin_obj.level
|
||||
|
||||
p.send_notice(nick_from=dnickname,nick_to=nickname, msg=f" ***************** LISTE DES COMMANDES *****************")
|
||||
await p.send_notice(nick_from=dnickname,nick_to=nickname, msg=f" ***************** LISTE DES COMMANDES *****************")
|
||||
header = f" {'Level':<8}| {'Command':<25}| {'Module':<15}| {'Description':<35}"
|
||||
line = "-"*75
|
||||
p.send_notice(nick_from=dnickname,nick_to=nickname, msg=header)
|
||||
p.send_notice(nick_from=dnickname,nick_to=nickname, msg=f" {line}")
|
||||
await p.send_notice(nick_from=dnickname,nick_to=nickname, msg=header)
|
||||
await p.send_notice(nick_from=dnickname,nick_to=nickname, msg=f" {line}")
|
||||
for cmd in self.Commands.get_commands_by_level(current_level):
|
||||
if module is None or cmd.module_name.lower() == module.lower():
|
||||
p.send_notice(
|
||||
await p.send_notice(
|
||||
nick_from=dnickname,
|
||||
nick_to=nickname,
|
||||
msg=f" {color_black}{cmd.command_level:<8}{color_nogc}| {cmd.command_name:<25}| {cmd.module_name:<15}| {cmd.description:<35}"
|
||||
@@ -465,18 +494,18 @@ class Irc:
|
||||
self.Logs.info(f"The nickname {nickname} already exist! (sent by {sender})")
|
||||
return False
|
||||
|
||||
def thread_check_for_new_version(self, fromuser: str) -> None:
|
||||
async def thread_check_for_new_version(self, fromuser: str) -> None:
|
||||
dnickname = self.Config.SERVICE_NICKNAME
|
||||
|
||||
if self.Base.check_for_new_version(True):
|
||||
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.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" Please run (git pull origin main) in the current folder")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" New Version available : {self.Config.CURRENT_VERSION} >>> {self.Config.LATEST_VERSION}")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" Please run (git pull origin main) in the current folder")
|
||||
else:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" You have the latest version of defender")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" You have the latest version of defender")
|
||||
|
||||
return None
|
||||
|
||||
def cmd(self, data: list[str]) -> None:
|
||||
async def cmd(self, data: list[str]) -> None:
|
||||
"""Parse server response
|
||||
|
||||
Args:
|
||||
@@ -494,7 +523,7 @@ class Irc:
|
||||
|
||||
for parsed in self.Protocol.Handler.get_ircd_commands():
|
||||
if parsed.command_name.upper() == parsed_protocol:
|
||||
parsed.func(original_response)
|
||||
await parsed.func(original_response)
|
||||
for module in modules:
|
||||
module.class_instance.cmd(original_response)
|
||||
|
||||
@@ -509,7 +538,7 @@ class Irc:
|
||||
except Exception as err:
|
||||
self.Logs.error(f"General Error: {err}", exc_info=True)
|
||||
|
||||
def hcmds(self, user: str, channel: Union[str, None], cmd: list, fullcmd: list = []) -> None:
|
||||
async def hcmds(self, user: str, channel: Union[str, None], cmd: list, fullcmd: list = []) -> None:
|
||||
"""Create
|
||||
|
||||
Args:
|
||||
@@ -560,13 +589,13 @@ class Irc:
|
||||
case 'notallowed':
|
||||
try:
|
||||
current_command = str(cmd[0])
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
msg=tr('[ %s%s%s ] - Access denied to %s', RED, current_command.upper(), NOGC, fromuser),
|
||||
nick_from=dnickname,
|
||||
channel=dchanlog
|
||||
)
|
||||
|
||||
self.Protocol.send_notice(
|
||||
await self.Protocol.send_notice(
|
||||
nick_from=dnickname,
|
||||
nick_to=fromuser,
|
||||
msg=tr('Access denied!')
|
||||
@@ -1012,7 +1041,7 @@ class Irc:
|
||||
case 'help':
|
||||
# Syntax. !help [module_name]
|
||||
module_name = str(cmd[1]) if len(cmd) == 2 else None
|
||||
self.generate_help_menu(nickname=fromuser, module=module_name)
|
||||
await self.generate_help_menu(nickname=fromuser, module=module_name)
|
||||
return None
|
||||
|
||||
case 'load':
|
||||
@@ -1119,14 +1148,14 @@ class Irc:
|
||||
loaded = True
|
||||
|
||||
if loaded:
|
||||
self.Protocol.send_notice(
|
||||
await self.Protocol.send_notice(
|
||||
nick_from=dnickname,
|
||||
nick_to=fromuser,
|
||||
msg=tr('%s - %sLoaded%s by %s on %s', module, GREEN, NOGC, loaded_user, loaded_datetime)
|
||||
)
|
||||
loaded = False
|
||||
else:
|
||||
self.Protocol.send_notice(
|
||||
await self.Protocol.send_notice(
|
||||
nick_from=dnickname,
|
||||
nick_to=fromuser,
|
||||
msg=tr('%s - %sNot Loaded%s', module, RED, NOGC)
|
||||
@@ -1150,11 +1179,17 @@ class Irc:
|
||||
|
||||
case 'show_threads':
|
||||
for thread in self.Base.running_threads:
|
||||
self.Protocol.send_notice(
|
||||
await self.Protocol.send_notice(
|
||||
nick_from=dnickname,
|
||||
nick_to=fromuser,
|
||||
msg=f">> {thread.name} ({thread.is_alive()})"
|
||||
)
|
||||
|
||||
asyncio.create_task(self.new_coro(), name='my_new_coro')
|
||||
for task in asyncio.all_tasks():
|
||||
print(task.get_name())
|
||||
print(task)
|
||||
|
||||
return None
|
||||
|
||||
case 'show_channels':
|
||||
@@ -1282,3 +1317,8 @@ class Irc:
|
||||
|
||||
case _:
|
||||
pass
|
||||
|
||||
async def new_coro(self):
|
||||
self.Logs.debug("Creating new coro")
|
||||
await asyncio.sleep(5)
|
||||
self.Logs.debug("End of the coro")
|
||||
@@ -15,7 +15,7 @@ class ServiceLogging:
|
||||
self.SERVER_PREFIX = None
|
||||
self.LOGGING_CONSOLE = True
|
||||
|
||||
self.LOG_FILTERS: list[str] = ["PING", f":{self.SERVER_PREFIX}auth", "['PASS'"]
|
||||
self.LOG_FILTERS: list[str] = [f":{self.SERVER_PREFIX}auth", "['PASS'"]
|
||||
|
||||
self.file_handler = None
|
||||
self.stdout_handler = None
|
||||
|
||||
@@ -84,7 +84,7 @@ class Module:
|
||||
self.__Logs.debug(f"[MOD_HEADER ERROR] Impossible to remove the module header ({module_name})")
|
||||
return False
|
||||
|
||||
def load_one_module(self, uplink: 'Irc', module_name: str, nickname: str, is_default: bool = False) -> bool:
|
||||
async def load_one_module(self, uplink: 'Irc', module_name: str, nickname: str, is_default: bool = False) -> bool:
|
||||
|
||||
module_folder, module_name, class_name = self.get_module_information(module_name)
|
||||
|
||||
@@ -97,7 +97,7 @@ class Module:
|
||||
if self.model_is_module_exist(module_name):
|
||||
# Si le module existe dans la variable globale retourne False
|
||||
self.__Logs.debug(f"Module [{module_folder}.{module_name}] exist in the local variable!")
|
||||
uplink.Protocol.send_priv_msg(
|
||||
await uplink.Protocol.send_priv_msg(
|
||||
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}",
|
||||
channel=self.__Config.SERVICE_CHANLOG
|
||||
@@ -110,12 +110,12 @@ class Module:
|
||||
try:
|
||||
loaded_module = importlib.import_module(f'mods.{module_folder}.{module_name}')
|
||||
my_class = getattr(loaded_module, class_name, None) # Récuperer le nom de classe
|
||||
create_instance_of_the_class = my_class(uplink) # Créer une nouvelle instance de la classe
|
||||
create_instance_of_the_class = my_class(uplink) # Créer une nouvelle instance de la classe
|
||||
self.create_module_header(create_instance_of_the_class.MOD_HEADER)
|
||||
except AttributeError as attr:
|
||||
red = uplink.Config.COLORS.red
|
||||
nogc = uplink.Config.COLORS.nogc
|
||||
uplink.Protocol.send_priv_msg(
|
||||
await uplink.Protocol.send_priv_msg(
|
||||
nick_from=self.__Config.SERVICE_NICKNAME,
|
||||
msg=tr("[%sMODULE ERROR%s] Module %s is facing issues! %s", red, nogc, module_name, attr),
|
||||
channel=self.__Config.SERVICE_CHANLOG
|
||||
@@ -124,7 +124,7 @@ class Module:
|
||||
return False
|
||||
|
||||
if not hasattr(create_instance_of_the_class, 'cmd'):
|
||||
uplink.Protocol.send_priv_msg(
|
||||
await uplink.Protocol.send_priv_msg(
|
||||
nick_from=self.__Config.SERVICE_NICKNAME,
|
||||
msg=tr("cmd method is not available in the module (%s)", module_name),
|
||||
channel=self.__Config.SERVICE_CHANLOG
|
||||
@@ -137,7 +137,7 @@ class Module:
|
||||
if self.model_insert_module(MModule(module_name, class_name, create_instance_of_the_class)):
|
||||
# Enregistrer le module dans la base de données
|
||||
self.db_register_module(module_name, nickname, is_default)
|
||||
uplink.Protocol.send_priv_msg(
|
||||
await uplink.Protocol.send_priv_msg(
|
||||
nick_from=self.__Config.SERVICE_NICKNAME,
|
||||
msg=tr("Module %s loaded!", module_name),
|
||||
channel=self.__Config.SERVICE_CHANLOG
|
||||
@@ -399,7 +399,7 @@ class Module:
|
||||
OPERATION DEDICATED TO DATABASE MANAGEMENT
|
||||
'''
|
||||
|
||||
def db_load_all_existing_modules(self, uplink: 'Irc') -> bool:
|
||||
async def db_load_all_existing_modules(self, uplink: 'Irc') -> bool:
|
||||
"""Charge les modules qui existe déja dans la base de données
|
||||
|
||||
Returns:
|
||||
@@ -408,7 +408,7 @@ class Module:
|
||||
self.__Logs.debug("[DB LOAD MODULE] Loading modules from the database!")
|
||||
result = self.__Base.db_execute_query(f"SELECT module_name FROM {self.__Config.TABLE_MODULE}")
|
||||
for r in result.fetchall():
|
||||
self.load_one_module(uplink, r[0], 'sys', True)
|
||||
await self.load_one_module(uplink, r[0], 'sys', True)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
27
defender.py
27
defender.py
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from core import install
|
||||
|
||||
#############################################
|
||||
@@ -9,14 +10,24 @@ from core import install
|
||||
# UnrealIRCD 6.2.2 or higher #
|
||||
#############################################
|
||||
|
||||
try:
|
||||
# install.update_packages()
|
||||
async def main():
|
||||
from core.loader import Loader
|
||||
loader = Loader()
|
||||
loader.Irc.init_irc()
|
||||
await loader.Irc.run()
|
||||
|
||||
except AssertionError as ae:
|
||||
print(f'Assertion Error -> {ae}')
|
||||
except KeyboardInterrupt as k:
|
||||
# ircInstance.Base.execute_periodic_action()
|
||||
...
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main(), debug=True)
|
||||
|
||||
|
||||
|
||||
# try:
|
||||
# # install.update_packages()
|
||||
# from core.loader import Loader
|
||||
# loader = Loader()
|
||||
# loader.Irc.init_irc()
|
||||
|
||||
# except AssertionError as ae:
|
||||
# print(f'Assertion Error -> {ae}')
|
||||
# except KeyboardInterrupt as k:
|
||||
# # ircInstance.Base.execute_periodic_action()
|
||||
# ...
|
||||
@@ -43,7 +43,7 @@ class Defender(IModule):
|
||||
# self.Base.db_execute_query(table_trusted)
|
||||
return None
|
||||
|
||||
def load(self):
|
||||
async def load(self):
|
||||
|
||||
# Add module schemas
|
||||
self.Schemas = schemas
|
||||
@@ -98,8 +98,8 @@ class Defender(IModule):
|
||||
self.Base.create_thread(func=thds.thread_autolimit, func_args=(self, ))
|
||||
|
||||
if self.ModConfig.reputation == 1:
|
||||
self.Protocol.send_sjoin(self.Config.SALON_JAIL)
|
||||
self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} SAMODE {self.Config.SALON_JAIL} +o {self.Config.SERVICE_NICKNAME}")
|
||||
await self.Protocol.send_sjoin(self.Config.SALON_JAIL)
|
||||
await self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} SAMODE {self.Config.SALON_JAIL} +o {self.Config.SERVICE_NICKNAME}")
|
||||
|
||||
def __onload(self):
|
||||
|
||||
@@ -164,7 +164,7 @@ class Defender(IModule):
|
||||
exec_query = self.Base.db_execute_query(q_insert, mes_donnees)
|
||||
pass
|
||||
|
||||
def join_saved_channels(self) -> None:
|
||||
async def join_saved_channels(self) -> None:
|
||||
"""_summary_
|
||||
"""
|
||||
try:
|
||||
@@ -178,10 +178,10 @@ class Defender(IModule):
|
||||
|
||||
for channel in channels:
|
||||
chan = channel[0]
|
||||
self.Protocol.send_sjoin(chan)
|
||||
await self.Protocol.send_sjoin(chan)
|
||||
if chan == jail_chan:
|
||||
self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} +{dumodes} {dnickname}")
|
||||
self.Protocol.send2socket(f":{service_id} MODE {jail_chan} +{jail_chan_mode}")
|
||||
await self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} +{dumodes} {dnickname}")
|
||||
await self.Protocol.send2socket(f":{service_id} MODE {jail_chan} +{jail_chan_mode}")
|
||||
|
||||
return None
|
||||
|
||||
@@ -243,7 +243,7 @@ class Defender(IModule):
|
||||
except Exception as err:
|
||||
self.Logs.error(f"General Error: {err}", exc_info=True)
|
||||
|
||||
def hcmds(self, user: str, channel: Any, cmd: list, fullcmd: list = []) -> None:
|
||||
async def hcmds(self, user: str, channel: Any, cmd: list, fullcmd: list = []) -> None:
|
||||
u = self.User.get_user(user)
|
||||
if u is None:
|
||||
return None
|
||||
@@ -264,10 +264,10 @@ class Defender(IModule):
|
||||
case 'show_reputation':
|
||||
|
||||
if not self.Reputation.UID_REPUTATION_DB:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg="No one is suspected")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg="No one is suspected")
|
||||
|
||||
for suspect in self.Reputation.UID_REPUTATION_DB:
|
||||
self.Protocol.send_notice(nick_from=dnickname,
|
||||
await self.Protocol.send_notice(nick_from=dnickname,
|
||||
nick_to=fromuser,
|
||||
msg=f" Uid: {suspect.uid} | Nickname: {suspect.nickname} | Reputation: {suspect.score_connexion} | Secret code: {suspect.secret_code} | Connected on: {suspect.connexion_datetime}")
|
||||
|
||||
@@ -279,7 +279,7 @@ class Defender(IModule):
|
||||
get_reputation = self.Reputation.get_reputation(jailed_UID)
|
||||
|
||||
if get_reputation is None:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" No code is requested ...")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" No code is requested ...")
|
||||
return False
|
||||
|
||||
jailed_IP = get_reputation.remote_ip
|
||||
@@ -293,30 +293,30 @@ class Defender(IModule):
|
||||
color_black = self.Config.COLORS.black
|
||||
|
||||
if release_code == get_reputation.secret_code:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg="Bon mot de passe. Allez du vent !", channel=jailed_salon)
|
||||
await 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:
|
||||
for chan in self.Channel.UID_CHANNEL_DB:
|
||||
if chan.name != jailed_salon:
|
||||
self.Protocol.send2socket(f":{service_id} MODE {chan.name} -b {jailed_nickname}!*@*")
|
||||
await self.Protocol.send2socket(f":{service_id} MODE {chan.name} -b {jailed_nickname}!*@*")
|
||||
|
||||
self.Reputation.delete(jailed_UID)
|
||||
self.Logs.debug(f'{jailed_UID} - {jailed_nickname} removed from REPUTATION_DB')
|
||||
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}")
|
||||
await self.Protocol.send_sapart(nick_to_sapart=jailed_nickname, channel_name=jailed_salon)
|
||||
await self.Protocol.send_sajoin(nick_to_sajoin=jailed_nickname, channel_name=welcome_salon)
|
||||
await self.Protocol.send2socket(f":{link} REPUTATION {jailed_IP} {self.ModConfig.reputation_score_after_release}")
|
||||
u.score_connexion = reputation_seuil + 1
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname,
|
||||
await 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)
|
||||
|
||||
else:
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg="Mauvais password",
|
||||
channel=jailed_salon
|
||||
)
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
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}",
|
||||
nick_to=jailed_nickname
|
||||
@@ -324,7 +324,7 @@ class Defender(IModule):
|
||||
|
||||
except IndexError as ie:
|
||||
self.Logs.error(f'Index Error: {ie}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} code [code]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} code [code]")
|
||||
except KeyError as ke:
|
||||
self.Logs.error(f'_hcmd code: KeyError {ke}')
|
||||
|
||||
@@ -333,8 +333,8 @@ class Defender(IModule):
|
||||
# autolimit on
|
||||
# autolimit set [amount] [interval]
|
||||
if len(cmd) < 2:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON")
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]")
|
||||
return None
|
||||
|
||||
arg = str(cmd[1]).lower()
|
||||
@@ -345,16 +345,16 @@ class Defender(IModule):
|
||||
self.update_configuration('autolimit', 1)
|
||||
self.autolimit_isRunning = True
|
||||
self.Base.create_thread(func=thds.thread_autolimit, func_args=(self, ))
|
||||
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)
|
||||
await 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:
|
||||
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)
|
||||
await 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':
|
||||
if self.ModConfig.autolimit == 1:
|
||||
self.update_configuration('autolimit', 0)
|
||||
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)
|
||||
await 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:
|
||||
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)
|
||||
await 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':
|
||||
amount = int(cmd[2])
|
||||
@@ -362,19 +362,19 @@ class Defender(IModule):
|
||||
|
||||
self.update_configuration('autolimit_amount', amount)
|
||||
self.update_configuration('autolimit_interval', interval)
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Amount set to ({amount}) | Interval set to ({interval})",
|
||||
channel=self.Config.SERVICE_CHANLOG
|
||||
)
|
||||
|
||||
case _:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON")
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]")
|
||||
|
||||
except Exception as err:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON")
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} ON")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"/msg {self.Config.SERVICE_NICKNAME} {command.upper()} SET [AMOUNT] [INTERVAL]")
|
||||
self.Logs.error(f"Value Error -> {err}")
|
||||
|
||||
case 'reputation':
|
||||
@@ -396,30 +396,30 @@ class Defender(IModule):
|
||||
if activation == 'on':
|
||||
|
||||
if self.ModConfig.reputation == 1:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Already activated", channel=dchanlog)
|
||||
await 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
|
||||
|
||||
# self.update_db_configuration('reputation', 1)
|
||||
self.update_configuration(key, 1)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Activated by {fromuser}", channel=dchanlog)
|
||||
await 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.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} MODE {jail_chan} +{jail_chan_mode}")
|
||||
await self.Protocol.send_join_chan(uidornickname=dnickname, channel=jail_chan)
|
||||
await self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} +{dumodes} {dnickname}")
|
||||
await self.Protocol.send2socket(f":{service_id} MODE {jail_chan} +{jail_chan_mode}")
|
||||
|
||||
if self.ModConfig.reputation_sg == 1:
|
||||
for chan in self.Channel.UID_CHANNEL_DB:
|
||||
if chan.name != jail_chan:
|
||||
self.Protocol.send2socket(f":{service_id} MODE {chan.name} +b ~security-group:unknown-users")
|
||||
self.Protocol.send2socket(f":{service_id} MODE {chan.name} +eee ~security-group:webirc-users ~security-group:known-users ~security-group:websocket-users")
|
||||
await self.Protocol.send2socket(f":{service_id} MODE {chan.name} +b ~security-group:unknown-users")
|
||||
await self.Protocol.send2socket(f":{service_id} MODE {chan.name} +eee ~security-group:webirc-users ~security-group:known-users ~security-group:websocket-users")
|
||||
|
||||
self.Channel.db_query_channel('add', self.module_name, jail_chan)
|
||||
|
||||
if activation == 'off':
|
||||
|
||||
if self.ModConfig.reputation == 0:
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Already deactivated",
|
||||
channel=dchanlog
|
||||
@@ -428,19 +428,19 @@ class Defender(IModule):
|
||||
|
||||
self.update_configuration(key, 0)
|
||||
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg=f"[ {self.Config.COLORS.red}REPUTATION{self.Config.COLORS.black} ] : Deactivated by {fromuser}",
|
||||
channel=dchanlog
|
||||
)
|
||||
self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} -{dumodes} {dnickname}")
|
||||
self.Protocol.send2socket(f":{service_id} MODE {jail_chan} -sS")
|
||||
self.Protocol.send2socket(f":{service_id} PART {jail_chan}")
|
||||
await self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} -{dumodes} {dnickname}")
|
||||
await self.Protocol.send2socket(f":{service_id} MODE {jail_chan} -sS")
|
||||
await self.Protocol.send2socket(f":{service_id} PART {jail_chan}")
|
||||
|
||||
for chan in self.Channel.UID_CHANNEL_DB:
|
||||
if chan.name != jail_chan:
|
||||
self.Protocol.send2socket(f":{service_id} MODE {chan.name} -b ~security-group:unknown-users")
|
||||
self.Protocol.send2socket(f":{service_id} MODE {chan.name} -eee ~security-group:webirc-users ~security-group:known-users ~security-group:websocket-users")
|
||||
await self.Protocol.send2socket(f":{service_id} MODE {chan.name} -b ~security-group:unknown-users")
|
||||
await self.Protocol.send2socket(f":{service_id} MODE {chan.name} -eee ~security-group:webirc-users ~security-group:known-users ~security-group:websocket-users")
|
||||
|
||||
self.Channel.db_query_channel('del', self.module_name, jail_chan)
|
||||
|
||||
@@ -450,7 +450,7 @@ class Defender(IModule):
|
||||
match get_options:
|
||||
case 'release':
|
||||
# .reputation release [nick]
|
||||
p = self.Protocol
|
||||
p = await self.Protocol
|
||||
link = self.Config.SERVEUR_LINK
|
||||
jailed_salon = self.Config.SALON_JAIL
|
||||
welcome_salon = self.Config.SALON_LIBERER
|
||||
@@ -507,7 +507,7 @@ class Defender(IModule):
|
||||
if get_value == 'on':
|
||||
|
||||
if self.ModConfig.reputation_ban_all_chan == 1:
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already activated",
|
||||
channel=dchanlog
|
||||
@@ -517,7 +517,7 @@ class Defender(IModule):
|
||||
# self.update_db_configuration(key, 1)
|
||||
self.update_configuration(key, 1)
|
||||
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Activated by {fromuser}",
|
||||
channel=dchanlog
|
||||
@@ -525,7 +525,7 @@ class Defender(IModule):
|
||||
|
||||
elif get_value == 'off':
|
||||
if self.ModConfig.reputation_ban_all_chan == 0:
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already deactivated",
|
||||
channel=dchanlog
|
||||
@@ -535,7 +535,7 @@ class Defender(IModule):
|
||||
# self.update_db_configuration(key, 0)
|
||||
self.update_configuration(key, 0)
|
||||
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Deactivated by {fromuser}",
|
||||
channel=dchanlog
|
||||
@@ -548,71 +548,71 @@ class Defender(IModule):
|
||||
# self.update_db_configuration(key, reputation_seuil)
|
||||
self.update_configuration(key, reputation_seuil)
|
||||
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
nick_from=dnickname,
|
||||
msg=f"[ {self.Config.COLORS.green}REPUTATION SEUIL{self.Config.COLORS.black} ] : Limit set to {str(reputation_seuil)} by {fromuser}",
|
||||
channel=dchanlog
|
||||
)
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation set to {reputation_seuil}")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation set to {reputation_seuil}")
|
||||
|
||||
case 'timer':
|
||||
reputation_timer = int(cmd[3])
|
||||
key = 'reputation_timer'
|
||||
self.update_configuration(key, reputation_timer)
|
||||
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
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}",
|
||||
channel=dchanlog
|
||||
)
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation set to {reputation_timer}")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation set to {reputation_timer}")
|
||||
|
||||
case 'score_after_release':
|
||||
reputation_score_after_release = int(cmd[3])
|
||||
key = 'reputation_score_after_release'
|
||||
self.update_configuration(key, reputation_score_after_release)
|
||||
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
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}",
|
||||
channel=dchanlog
|
||||
)
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation score after release set to {reputation_score_after_release}")
|
||||
await 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':
|
||||
reputation_sg = int(cmd[3])
|
||||
key = 'reputation_sg'
|
||||
self.update_configuration(key, reputation_sg)
|
||||
|
||||
self.Protocol.send_priv_msg(
|
||||
await self.Protocol.send_priv_msg(
|
||||
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}",
|
||||
channel=dchanlog
|
||||
)
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation score after release set to {reputation_sg}")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Reputation score after release set to {reputation_sg}")
|
||||
|
||||
case _:
|
||||
self.Protocol.send_notice(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 release [nickname]")
|
||||
self.Protocol.send_notice(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 limit [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.send_notice(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 action [kill|None]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation [ON/OFF]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation release [nickname]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set banallchan [ON/OFF]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set limit [1234]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set score_after_release [1234]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set timer [1234]")
|
||||
await 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:
|
||||
self.Logs.warning(f'{ie}')
|
||||
self.Protocol.send_notice(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 release [nickname]")
|
||||
self.Protocol.send_notice(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 limit [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.send_notice(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 action [kill|None]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation [ON/OFF]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation release [nickname]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set banallchan [ON/OFF]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set limit [1234]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set score_after_release [1234]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f" Right command : /msg {dnickname} reputation set timer [1234]")
|
||||
await 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:
|
||||
self.Logs.warning(f'{ve}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" La valeur devrait etre un entier >= 0")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=" La valeur devrait etre un entier >= 0")
|
||||
|
||||
case 'proxy_scan':
|
||||
|
||||
@@ -628,11 +628,11 @@ class Defender(IModule):
|
||||
set_key = str(cmd[1]).lower()
|
||||
|
||||
if set_key != 'set':
|
||||
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.send_notice(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 abuseipdb_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.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]')
|
||||
await 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
|
||||
action = str(cmd[3]).lower() # => on / off
|
||||
@@ -641,105 +641,105 @@ class Defender(IModule):
|
||||
case 'local_scan':
|
||||
if action == 'on':
|
||||
if self.ModConfig.local_scan == 1:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 1)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if self.ModConfig.local_scan == 0:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 0)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if action == 'on':
|
||||
if self.ModConfig.psutil_scan == 1:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 1)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if self.ModConfig.psutil_scan == 0:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 0)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if action == 'on':
|
||||
if self.ModConfig.abuseipdb_scan == 1:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 1)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if self.ModConfig.abuseipdb_scan == 0:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 0)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if action == 'on':
|
||||
if self.ModConfig.freeipapi_scan == 1:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 1)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if self.ModConfig.freeipapi_scan == 0:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 0)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if action == 'on':
|
||||
if self.ModConfig.cloudfilt_scan == 1:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Already activated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 1)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_green}PROXY_SCAN {option.upper()}{color_black} ] : Activated by {fromuser}", channel=dchanlog)
|
||||
await 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':
|
||||
if self.ModConfig.cloudfilt_scan == 0:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Already Deactivated", channel=dchanlog)
|
||||
return None
|
||||
|
||||
self.update_configuration(option, 0)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
|
||||
await self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {color_red}PROXY_SCAN {option.upper()}{color_black} ] : Deactivated by {fromuser}", channel=dchanlog)
|
||||
|
||||
case _:
|
||||
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.send_notice(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 abuseipdb_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.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]')
|
||||
else:
|
||||
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.send_notice(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 abuseipdb_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.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set cloudfilt_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set local_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set psutil_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set abuseipdb_scan [ON/OFF]')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Right command : /msg {dnickname} proxy_scan set freeipapi_scan [ON/OFF]')
|
||||
await 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':
|
||||
# .flood on/off
|
||||
@@ -754,21 +754,21 @@ class Defender(IModule):
|
||||
key = 'flood'
|
||||
if activation == 'on':
|
||||
if self.ModConfig.flood == 1:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Already activated", channel=dchanlog)
|
||||
await 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
|
||||
|
||||
self.update_configuration(key, 1)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Activated by {fromuser}", channel=dchanlog)
|
||||
await 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 self.ModConfig.flood == 0:
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.red}FLOOD{self.Config.COLORS.black} ] : Already Deactivated", channel=dchanlog)
|
||||
await 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
|
||||
|
||||
self.update_configuration(key, 0)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Deactivated by {fromuser}", channel=dchanlog)
|
||||
await 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:
|
||||
set_key = str(cmd[2]).lower()
|
||||
@@ -780,7 +780,7 @@ class Defender(IModule):
|
||||
set_value = int(cmd[3])
|
||||
self.update_configuration(key, set_value)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname,
|
||||
await 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}",
|
||||
channel=dchanlog)
|
||||
|
||||
@@ -789,7 +789,7 @@ class Defender(IModule):
|
||||
set_value = int(cmd[3])
|
||||
self.update_configuration(key, set_value)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname,
|
||||
await 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}",
|
||||
channel=dchanlog)
|
||||
|
||||
@@ -798,7 +798,7 @@ class Defender(IModule):
|
||||
set_value = int(cmd[3])
|
||||
self.update_configuration(key, set_value)
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname,
|
||||
await 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}",
|
||||
channel=dchanlog)
|
||||
|
||||
@@ -814,33 +814,33 @@ class Defender(IModule):
|
||||
color_black = self.Config.COLORS.black
|
||||
nogc = self.Config.COLORS.nogc
|
||||
try:
|
||||
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.send_notice(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_after_release ==> {self.ModConfig.reputation_score_after_release}')
|
||||
self.Protocol.send_notice(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_timer ==> {self.ModConfig.reputation_timer}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=' [Proxy_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.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.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.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.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.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' [{color_green if self.ModConfig.autolimit == 1 else color_red}Autolimit{nogc}] ==> {self.ModConfig.autolimit}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.autolimit == 1 else color_red}Autolimit Amount{nogc} ==> {self.ModConfig.autolimit_amount}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.autolimit == 1 else color_red}Autolimit Interval{nogc} ==> {self.ModConfig.autolimit_interval}')
|
||||
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.send_notice(nick_from=dnickname, nick_to=fromuser, msg=' flood_action ==> Coming soon')
|
||||
self.Protocol.send_notice(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_time ==> {self.ModConfig.flood_time}')
|
||||
self.Protocol.send_notice(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' [{color_green if self.ModConfig.flood == 1 else color_red}Sentinel{nogc}] ==> {self.ModConfig.sentinel}')
|
||||
await 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}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_seuil ==> {self.ModConfig.reputation_seuil}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_after_release ==> {self.ModConfig.reputation_score_after_release}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_ban_all_chan ==> {self.ModConfig.reputation_ban_all_chan}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' reputation_timer ==> {self.ModConfig.reputation_timer}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=' [Proxy_scan]')
|
||||
await 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}')
|
||||
await 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}')
|
||||
await 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}')
|
||||
await 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}')
|
||||
await 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}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' [{color_green if self.ModConfig.autolimit == 1 else color_red}Autolimit{nogc}] ==> {self.ModConfig.autolimit}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.autolimit == 1 else color_red}Autolimit Amount{nogc} ==> {self.ModConfig.autolimit_amount}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' {color_green if self.ModConfig.autolimit == 1 else color_red}Autolimit Interval{nogc} ==> {self.ModConfig.autolimit_interval}')
|
||||
await 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}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=' flood_action ==> Coming soon')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_message ==> {self.ModConfig.flood_message}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_time ==> {self.ModConfig.flood_time}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' flood_timer ==> {self.ModConfig.flood_timer}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' [{color_green if self.ModConfig.flood == 1 else color_red}Sentinel{nogc}] ==> {self.ModConfig.sentinel}')
|
||||
except KeyError as ke:
|
||||
self.Logs.error(f"Key Error : {ke}")
|
||||
|
||||
case 'info':
|
||||
try:
|
||||
if len(cmd) < 2:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Syntax. /msg {dnickname} INFO [nickname]")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"Syntax. /msg {dnickname} INFO [nickname]")
|
||||
return None
|
||||
|
||||
nickoruid = cmd[1]
|
||||
@@ -849,22 +849,22 @@ class Defender(IModule):
|
||||
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]
|
||||
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' UID : {UserObject.uid}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' NICKNAME : {UserObject.nickname}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' USERNAME : {UserObject.username}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' REALNAME : {UserObject.realname}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' HOSTNAME : {UserObject.hostname}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' VHOST : {UserObject.vhost}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' IP : {UserObject.remote_ip}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Country : {UserObject.geoip}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' WebIrc : {UserObject.isWebirc}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' WebWebsocket : {UserObject.isWebsocket}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' REPUTATION : {UserObject.score_connexion}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' MODES : {UserObject.umodes}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' CHANNELS : {", ".join(channels)}')
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' CONNECTION TIME : {UserObject.connexion_datetime}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' UID : {UserObject.uid}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' NICKNAME : {UserObject.nickname}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' USERNAME : {UserObject.username}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' REALNAME : {UserObject.realname}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' HOSTNAME : {UserObject.hostname}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' VHOST : {UserObject.vhost}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' IP : {UserObject.remote_ip}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' Country : {UserObject.geoip}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' WebIrc : {UserObject.isWebirc}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' WebWebsocket : {UserObject.isWebsocket}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' REPUTATION : {UserObject.score_connexion}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' MODES : {UserObject.umodes}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' CHANNELS : {", ".join(channels)}')
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f' CONNECTION TIME : {UserObject.connexion_datetime}')
|
||||
else:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"This user {nickoruid} doesn't exist")
|
||||
await self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"This user {nickoruid} doesn't exist")
|
||||
|
||||
except KeyError as ke:
|
||||
self.Logs.warning(f"Key error info user : {ke}")
|
||||
@@ -883,8 +883,8 @@ class Defender(IModule):
|
||||
self.update_configuration('sentinel', 1)
|
||||
for chan in self.Channel.UID_CHANNEL_DB:
|
||||
if chan.name not in channel_to_dont_quit:
|
||||
self.Protocol.send_join_chan(uidornickname=dnickname, channel=chan.name)
|
||||
self.Protocol.send_priv_msg(dnickname, f"Sentinel mode activated on {channel}", channel=chan.name)
|
||||
await self.Protocol.send_join_chan(uidornickname=dnickname, channel=chan.name)
|
||||
await self.Protocol.send_priv_msg(dnickname, f"Sentinel mode activated on {channel}", channel=chan.name)
|
||||
return None
|
||||
|
||||
if activation == 'off':
|
||||
@@ -895,7 +895,7 @@ class Defender(IModule):
|
||||
self.update_configuration('sentinel', 0)
|
||||
for chan in self.Channel.UID_CHANNEL_DB:
|
||||
if chan.name not in channel_to_dont_quit:
|
||||
self.Protocol.send_part_chan(uidornickname=dnickname, channel=chan.name)
|
||||
self.Protocol.send_priv_msg(dnickname, f"Sentinel mode deactivated on {channel}", channel=chan.name)
|
||||
await self.Protocol.send_part_chan(uidornickname=dnickname, channel=chan.name)
|
||||
await self.Protocol.send_priv_msg(dnickname, f"Sentinel mode deactivated on {channel}", channel=chan.name)
|
||||
self.join_saved_channels()
|
||||
return None
|
||||
|
||||
@@ -58,7 +58,7 @@ def delete_vote_channel_from_database(uplink: 'Votekick', channel: str) -> bool:
|
||||
else:
|
||||
return False
|
||||
|
||||
def join_saved_channels(uplink: 'Votekick') -> None:
|
||||
async def join_saved_channels(uplink: 'Votekick') -> None:
|
||||
|
||||
param = {'module_name': uplink.module_name}
|
||||
result = uplink.Base.db_execute_query(f"SELECT id, channel_name FROM {uplink.Config.TABLE_CHANNEL} WHERE module_name = :module_name", param)
|
||||
@@ -68,7 +68,7 @@ def join_saved_channels(uplink: 'Votekick') -> None:
|
||||
for channel in channels:
|
||||
id_, chan = channel
|
||||
uplink.VoteKickManager.activate_new_channel(chan)
|
||||
uplink.Protocol.send_sjoin(channel=chan)
|
||||
uplink.Protocol.send2socket(f":{uplink.Config.SERVICE_NICKNAME} SAMODE {chan} +o {uplink.Config.SERVICE_NICKNAME}")
|
||||
await uplink.Protocol.send_sjoin(channel=chan)
|
||||
await uplink.Protocol.send2socket(f":{uplink.Config.SERVICE_NICKNAME} SAMODE {chan} +o {uplink.Config.SERVICE_NICKNAME}")
|
||||
|
||||
return None
|
||||
Reference in New Issue
Block a user