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
|
@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.
|
"""Envoit les commandes à envoyer au serveur.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -62,7 +62,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Sending PRIVMSG to a channel or to a nickname by batches
|
||||||
could be either channel or nickname not both together
|
could be either channel or nickname not both together
|
||||||
Args:
|
Args:
|
||||||
@@ -73,7 +73,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Sending NOTICE by batches
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -83,13 +83,13 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_link(self) -> None:
|
async def send_link(self) -> None:
|
||||||
"""Créer le link et envoyer les informations nécessaires pour la
|
"""Créer le link et envoyer les informations nécessaires pour la
|
||||||
connexion au serveur.
|
connexion au serveur.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Send a gline command to the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -102,7 +102,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_set_nick(self, newnickname: str) -> None:
|
async def send_set_nick(self, newnickname: str) -> None:
|
||||||
"""Change nickname of the server
|
"""Change nickname of the server
|
||||||
\n This method will also update the User object
|
\n This method will also update the User object
|
||||||
Args:
|
Args:
|
||||||
@@ -110,7 +110,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Set a mode to channel or to a nickname or for a user in a channel
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -121,7 +121,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -131,7 +131,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_ungline(self, nickname:str, hostname: str) -> None:
|
async def send_ungline(self, nickname:str, hostname: str) -> None:
|
||||||
"""_summary_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -140,7 +140,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -153,7 +153,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_unkline(self, nickname:str, hostname: str) -> None:
|
async def send_unkline(self, nickname:str, hostname: str) -> None:
|
||||||
"""_summary_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -162,7 +162,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Server will join a channel with pre defined umodes
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -170,7 +170,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -179,7 +179,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -188,7 +188,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -198,7 +198,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -208,7 +208,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_svsmode(self, nickname: str, user_mode: str) -> None:
|
async def send_svsmode(self, nickname: str, user_mode: str) -> None:
|
||||||
"""_summary_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -217,7 +217,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_svs2mode(self, nickname: str, user_mode: str) -> None:
|
async def send_svs2mode(self, nickname: str, user_mode: str) -> None:
|
||||||
"""_summary_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -226,7 +226,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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.
|
"""Log a client into his account.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -235,7 +235,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_svslogout(self, client_obj: 'MClient') -> None:
|
async def send_svslogout(self, client_obj: 'MClient') -> None:
|
||||||
"""Logout a client from his account
|
"""Logout a client from his account
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -243,7 +243,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Send quit message
|
||||||
- Delete uid from User object
|
- Delete uid from User object
|
||||||
- Delete uid from Reputation object
|
- Delete uid from Reputation object
|
||||||
@@ -255,7 +255,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Send UID to the server
|
||||||
- Insert User to User Object
|
- Insert User to User Object
|
||||||
Args:
|
Args:
|
||||||
@@ -271,7 +271,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Joining a channel
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -282,7 +282,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Part from a channel
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -292,7 +292,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -301,7 +301,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_raw(self, raw_command: str) -> None:
|
async def send_raw(self, raw_command: str) -> None:
|
||||||
"""Send raw message to the server
|
"""Send raw message to the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -313,7 +313,7 @@ class IProtocol(ABC):
|
|||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
|
|
||||||
@abstractmethod
|
@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.
|
"""Parse UID and return dictionary.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -324,7 +324,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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.
|
"""Parse quit and return dictionary.
|
||||||
>>> [':97KAAAAAB', 'QUIT', ':Quit:', 'this', 'is', 'my', 'reason', 'to', 'quit']
|
>>> [':97KAAAAAB', 'QUIT', ':Quit:', 'this', 'is', 'my', 'reason', 'to', 'quit']
|
||||||
Args:
|
Args:
|
||||||
@@ -335,7 +335,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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.
|
"""Parse nick changes and return dictionary.
|
||||||
>>> [':97KAAAAAC', 'NICK', 'testinspir', '1757360740']
|
>>> [':97KAAAAAC', 'NICK', 'testinspir', '1757360740']
|
||||||
|
|
||||||
@@ -349,7 +349,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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.
|
"""Parse PRIVMSG message.
|
||||||
>>> [':97KAAAAAE', 'PRIVMSG', '#welcome', ':This', 'is', 'my', 'public', 'message']
|
>>> [':97KAAAAAE', 'PRIVMSG', '#welcome', ':This', 'is', 'my', 'public', 'message']
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ class IProtocol(ABC):
|
|||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle svs2mode coming from a server
|
||||||
>>> [':00BAAAAAG', 'SVS2MODE', '001U01R03', '-r']
|
>>> [':00BAAAAAG', 'SVS2MODE', '001U01R03', '-r']
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle mode coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -382,7 +382,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle umode2 coming from a server
|
||||||
>>> [':adator_', 'UMODE2', '-i']
|
>>> [':adator_', 'UMODE2', '-i']
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle quit coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -399,7 +399,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle squit coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -407,7 +407,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle protoctl coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -415,7 +415,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle nick coming from a server
|
||||||
new nickname
|
new nickname
|
||||||
|
|
||||||
@@ -424,7 +424,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle sjoin coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -432,7 +432,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle part coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -440,7 +440,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle EOS coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -448,7 +448,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle REPUTATION coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -456,7 +456,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle uid message coming from the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -464,7 +464,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle PRIVMSG message coming from the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -472,7 +472,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Send a PONG message to the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -480,7 +480,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def on_server(self, server_msg: list[str]) -> None:
|
async def on_server(self, server_msg: list[str]) -> None:
|
||||||
"""_summary_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -488,7 +488,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Sending Server Version to the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -496,7 +496,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Sending TIME answer to a requestor
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -504,7 +504,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Sending a PING answer to requestor
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -512,7 +512,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle version coming from the server
|
||||||
\n ex. /version Defender
|
\n ex. /version Defender
|
||||||
Args:
|
Args:
|
||||||
@@ -520,7 +520,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle SMOD message coming from the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -528,7 +528,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Handle SASL coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -539,7 +539,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""Finalize sasl authentication
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -550,7 +550,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def on_md(self, server_msg: list[str]) -> None:
|
async def on_md(self, server_msg: list[str]) -> None:
|
||||||
"""Handle MD responses
|
"""Handle MD responses
|
||||||
[':001', 'MD', 'client', '001MYIZ03', 'certfp', ':d1235648...']
|
[':001', 'MD', 'client', '001MYIZ03', 'certfp', ':d1235648...']
|
||||||
Args:
|
Args:
|
||||||
@@ -558,7 +558,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
"""When a user is kicked out from a channel
|
||||||
|
|
||||||
Eg. ['@unrealircd.org...', ':001', 'KICK', '#jsonrpc', '001ELW13T', ':Kicked', 'from', 'JSONRPC', 'User']
|
Eg. ['@unrealircd.org...', ':001', 'KICK', '#jsonrpc', '001ELW13T', ':Kicked', 'from', 'JSONRPC', 'User']
|
||||||
@@ -567,7 +567,7 @@ class IProtocol(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def on_sethost(self, server_msg: list[str]) -> None:
|
async def on_sethost(self, server_msg: list[str]) -> None:
|
||||||
"""On SETHOST command
|
"""On SETHOST command
|
||||||
>>> [':001DN7305', 'SETHOST', ':netadmin.example.org']
|
>>> [':001DN7305', 'SETHOST', ':netadmin.example.org']
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class Unrealircd6(IProtocol):
|
|||||||
|
|
||||||
return None
|
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.
|
"""Envoit les commandes à envoyer au serveur.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -108,16 +108,19 @@ class Unrealircd6(IProtocol):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with self._Base.lock:
|
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:
|
if print_log:
|
||||||
self._Logs.debug(f'<< {message}')
|
self._Logs.debug(f'<< {message}')
|
||||||
|
|
||||||
except UnicodeDecodeError as ude:
|
except UnicodeDecodeError as ude:
|
||||||
self._Logs.error(f'Decode Error try iso-8859-1 - {ude} - {message}')
|
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:
|
except UnicodeEncodeError as uee:
|
||||||
self._Logs.error(f'Encode Error try iso-8859-1 - {uee} - {message}')
|
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:
|
except AssertionError as ae:
|
||||||
self._Logs.warning(f'Assertion Error {ae} - message: {message}')
|
self._Logs.warning(f'Assertion Error {ae} - message: {message}')
|
||||||
except SSLEOFError as soe:
|
except SSLEOFError as soe:
|
||||||
@@ -129,7 +132,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except AttributeError as ae:
|
except AttributeError as ae:
|
||||||
self._Logs.critical(f"Attribute Error: {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
|
"""Sending PRIVMSG to a channel or to a nickname by batches
|
||||||
could be either channel or nickname not both together
|
could be either channel or nickname not both together
|
||||||
Args:
|
Args:
|
||||||
@@ -150,18 +153,18 @@ class Unrealircd6(IProtocol):
|
|||||||
if not channel is None:
|
if not channel is None:
|
||||||
for i in range(0, len(str(msg)), batch_size):
|
for i in range(0, len(str(msg)), batch_size):
|
||||||
batch = str(msg)[i:i+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:
|
if not nick_to is None:
|
||||||
for i in range(0, len(str(msg)), batch_size):
|
for i in range(0, len(str(msg)), batch_size):
|
||||||
batch = str(msg)[i:i+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:
|
except Exception as err:
|
||||||
self._Logs.error(f"General Error: {err}")
|
self._Logs.error(f"General Error: {err}")
|
||||||
self._Logs.error(f"General Error: {nick_from} - {channel} - {nick_to}")
|
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
|
"""Sending NOTICE by batches
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -180,12 +183,12 @@ class Unrealircd6(IProtocol):
|
|||||||
|
|
||||||
for i in range(0, len(str(msg)), batch_size):
|
for i in range(0, len(str(msg)), batch_size):
|
||||||
batch = str(msg)[i:i+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:
|
except Exception as err:
|
||||||
self._Logs.error(f"General Error: {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
|
"""Créer le link et envoyer les informations nécessaires pour la
|
||||||
connexion au serveur.
|
connexion au serveur.
|
||||||
"""
|
"""
|
||||||
@@ -209,22 +212,22 @@ class Unrealircd6(IProtocol):
|
|||||||
version = self._Config.CURRENT_VERSION
|
version = self._Config.CURRENT_VERSION
|
||||||
unixtime = self._Utils.get_unixtime()
|
unixtime = self._Utils.get_unixtime()
|
||||||
|
|
||||||
self.send2socket(f":{server_id} PASS :{server_password}", print_log=False)
|
await 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")
|
await 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}")
|
await self.send2socket(f":{server_id} PROTOCTL EAUTH={server_link},{protocolversion},,{service_name}-v{version}")
|
||||||
self.send2socket(f":{server_id} PROTOCTL SID={server_id}")
|
await self.send2socket(f":{server_id} PROTOCTL SID={server_id}")
|
||||||
self.send2socket(f":{server_id} PROTOCTL BOOTED={unixtime}")
|
await self.send2socket(f":{server_id} PROTOCTL BOOTED={unixtime}")
|
||||||
self.send2socket(f":{server_id} SERVER {server_link} 1 :{service_info}")
|
await self.send2socket(f":{server_id} SERVER {server_link} 1 :{service_info}")
|
||||||
self.send2socket(f":{server_id} {service_nickname} :Reserved for services")
|
await 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}")
|
await self.send2socket(f":{server_id} UID {service_nickname} 1 {unixtime} {service_username} {service_hostname} {service_id} * {service_smodes} * * fwAAAQ== :{service_realname}")
|
||||||
self.send2socket("EOS")
|
await self.send2socket("EOS")
|
||||||
self.send_sjoin(service_channel_log)
|
await self.send_sjoin(service_channel_log)
|
||||||
self.send2socket(f":{server_id} TKL + Q * {service_nickname} {service_hostname} 0 {unixtime} :Reserved for services")
|
await 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":{service_id} MODE {service_channel_log} {service_cmodes}")
|
||||||
|
|
||||||
self._Logs.debug(f'>> {__name__} Link information sent to the server')
|
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
|
"""Send a gline command to the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -237,23 +240,23 @@ class Unrealircd6(IProtocol):
|
|||||||
"""
|
"""
|
||||||
# TKL + G user host set_by expire_timestamp set_at_timestamp :reason
|
# 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
|
return None
|
||||||
|
|
||||||
def send_set_nick(self, newnickname: str) -> None:
|
async def send_set_nick(self, newnickname: str) -> None:
|
||||||
"""Change nickname of the server
|
"""Change nickname of the server
|
||||||
\n This method will also update the User object
|
\n This method will also update the User object
|
||||||
Args:
|
Args:
|
||||||
newnickname (str): New nickname of the server
|
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)
|
user_obj = self._Irc.User.get_user(self._Config.SERVICE_NICKNAME)
|
||||||
self._Irc.User.update_nickname(user_obj.uid, newnickname)
|
self._Irc.User.update_nickname(user_obj.uid, newnickname)
|
||||||
return None
|
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
|
"""Set a mode to channel or to a nickname or for a user in a channel
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -273,50 +276,50 @@ class Unrealircd6(IProtocol):
|
|||||||
if not self._Irc.Channel.is_valid_channel(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}")
|
self._Logs.error(f"[MODE ERROR] The channel is not valid: {channel_name}")
|
||||||
return None
|
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
|
return None
|
||||||
|
|
||||||
if nickname and channel_name is 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
|
return None
|
||||||
|
|
||||||
if nickname is None and channel_name:
|
if nickname is None and channel_name:
|
||||||
if not self._Irc.Channel.is_valid_channel(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}")
|
self._Logs.error(f"[MODE ERROR] The channel is not valid: {channel_name}")
|
||||||
return None
|
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
|
||||||
|
|
||||||
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:
|
if not reason:
|
||||||
reason = 'Service Shutdown'
|
reason = 'Service Shutdown'
|
||||||
|
|
||||||
self.send2socket(f":{server_id} SQUIT {server_link} :{reason}")
|
await self.send2socket(f":{server_id} SQUIT {server_link} :{reason}")
|
||||||
return None
|
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
|
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
|
# 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
|
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
|
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
|
"""Server will join a channel with pre defined umodes
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -326,14 +329,14 @@ class Unrealircd6(IProtocol):
|
|||||||
self._Logs.error(f"The channel [{channel}] is not valid")
|
self._Logs.error(f"The channel [{channel}] is not valid")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
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.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.SERVICE_ID} MODE {channel} {self._Config.SERVICE_UMODES} {self._Config.SERVICE_ID}")
|
||||||
|
|
||||||
# Add defender to the channel uids list
|
# Add defender to the channel uids list
|
||||||
self._Irc.Channel.insert(self._Irc.Loader.Definition.MChannel(name=channel, uids=[self._Config.SERVICE_ID]))
|
self._Irc.Channel.insert(self._Irc.Loader.Definition.MChannel(name=channel, uids=[self._Config.SERVICE_ID]))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def 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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -349,7 +352,7 @@ class Unrealircd6(IProtocol):
|
|||||||
if user_obj is None or chan_obj is None:
|
if user_obj is None or chan_obj is None:
|
||||||
return 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)
|
self._Irc.Channel.delete_user_from_channel(chan_obj.name, user_obj.uid)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@@ -357,7 +360,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -383,18 +386,18 @@ class Unrealircd6(IProtocol):
|
|||||||
# Create the new channel with the uid
|
# Create the new channel with the uid
|
||||||
new_chan_obj = self._Irc.Loader.Definition.MChannel(name=channel_name, uids=[user_obj.uid])
|
new_chan_obj = self._Irc.Loader.Definition.MChannel(name=channel_name, uids=[user_obj.uid])
|
||||||
self._Irc.Channel.insert(new_chan_obj)
|
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:
|
else:
|
||||||
self._Irc.Channel.add_user_to_a_channel(channel_name=channel_name, uid=user_obj.uid)
|
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
|
return None
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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)
|
user_obj = self._Irc.User.get_user(nick_to_part)
|
||||||
|
|
||||||
if user_obj is None:
|
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)])
|
channels_list = ','.join([channel for channel in channels if self._Irc.Channel.is_valid_channel(channel)])
|
||||||
service_id = self._Config.SERVICE_ID
|
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
|
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)
|
user_obj = self._Irc.User.get_user(nick_to_part)
|
||||||
|
|
||||||
if user_obj is None:
|
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)])
|
channels_list = ','.join([channel for channel in channels if self._Irc.Channel.is_valid_channel(channel)])
|
||||||
keys_list = ','.join([key for key in keys])
|
keys_list = ','.join([key for key in keys])
|
||||||
service_id = self._Config.SERVICE_ID
|
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
|
return None
|
||||||
|
|
||||||
def send_svsmode(self, nickname: str, user_mode: str) -> None:
|
async def send_svsmode(self, nickname: str, user_mode: str) -> None:
|
||||||
try:
|
try:
|
||||||
user_obj = self._Irc.User.get_user(uidornickname=nickname)
|
user_obj = self._Irc.User.get_user(uidornickname=nickname)
|
||||||
service_uid = self._Config.SERVICE_ID
|
service_uid = self._Config.SERVICE_ID
|
||||||
@@ -427,7 +430,7 @@ class Unrealircd6(IProtocol):
|
|||||||
if user_obj is None:
|
if user_obj is None:
|
||||||
return 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
|
# Update new mode
|
||||||
self._Irc.User.update_mode(user_obj.uid, user_mode)
|
self._Irc.User.update_mode(user_obj.uid, user_mode)
|
||||||
@@ -436,7 +439,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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:
|
try:
|
||||||
user_obj = self._Irc.User.get_user(uidornickname=nickname)
|
user_obj = self._Irc.User.get_user(uidornickname=nickname)
|
||||||
service_uid = self._Config.SERVICE_ID
|
service_uid = self._Config.SERVICE_ID
|
||||||
@@ -444,7 +447,7 @@ class Unrealircd6(IProtocol):
|
|||||||
if user_obj is None:
|
if user_obj is None:
|
||||||
return 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
|
# Update new mode
|
||||||
self._Irc.User.update_mode(user_obj.uid, user_mode)
|
self._Irc.User.update_mode(user_obj.uid, user_mode)
|
||||||
@@ -453,7 +456,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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.
|
"""Log a client into his account.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -461,11 +464,11 @@ class Unrealircd6(IProtocol):
|
|||||||
user_account (str): The account of the user
|
user_account (str): The account of the user
|
||||||
"""
|
"""
|
||||||
try:
|
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:
|
except Exception as err:
|
||||||
self._Logs.error(f'General Error: {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
|
"""Logout a client from his account
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -474,13 +477,13 @@ class Unrealircd6(IProtocol):
|
|||||||
try:
|
try:
|
||||||
c_uid = client_obj.uid
|
c_uid = client_obj.uid
|
||||||
c_nickname = client_obj.nickname
|
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')
|
self.send_svs2mode(c_nickname, '-r')
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f'General Error: {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
|
"""Send quit message
|
||||||
- Delete uid from User object
|
- Delete uid from User object
|
||||||
- Delete uid from Reputation object
|
- Delete uid from Reputation object
|
||||||
@@ -494,7 +497,7 @@ class Unrealircd6(IProtocol):
|
|||||||
reputation_obj = self._Irc.Reputation.get_reputation(uidornickname=uid)
|
reputation_obj = self._Irc.Reputation.get_reputation(uidornickname=uid)
|
||||||
|
|
||||||
if not user_obj is None:
|
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)
|
self._Irc.User.delete(user_obj.uid)
|
||||||
|
|
||||||
if not reputation_obj is None:
|
if not reputation_obj is None:
|
||||||
@@ -505,7 +508,7 @@ class Unrealircd6(IProtocol):
|
|||||||
|
|
||||||
return None
|
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:
|
vhost: str, remote_ip: str, realname: str, print_log: bool = True) -> None:
|
||||||
"""Send UID to the server
|
"""Send UID to the server
|
||||||
- Insert User to User Object
|
- Insert User to User Object
|
||||||
@@ -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}"
|
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
|
return None
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Joining a channel
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -564,10 +567,10 @@ class Unrealircd6(IProtocol):
|
|||||||
self._Logs.error(f"The channel [{channel}] is not valid")
|
self._Logs.error(f"The channel [{channel}] is not valid")
|
||||||
return None
|
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:
|
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
|
# Add defender to the channel uids list
|
||||||
self._Irc.Channel.insert(self._Irc.Loader.Definition.MChannel(name=channel, uids=[user_obj.uid]))
|
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()
|
db_result = db_query.fetchone()
|
||||||
if db_result is not None:
|
if db_result is not None:
|
||||||
id_cmd_automode, mode = db_result
|
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
|
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
|
"""Part from a channel
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -604,25 +607,25 @@ class Unrealircd6(IProtocol):
|
|||||||
self._Logs.error(f"The channel [{channel}] is not valid")
|
self._Logs.error(f"The channel [{channel}] is not valid")
|
||||||
return None
|
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
|
# Add defender to the channel uids list
|
||||||
self._Irc.Channel.delete_user_from_channel(channel, u.uid)
|
self._Irc.Channel.delete_user_from_channel(channel, u.uid)
|
||||||
return None
|
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)
|
channel = self._Irc.Channel.is_valid_channel(channel_name)
|
||||||
if not channel:
|
if not channel:
|
||||||
self._Logs.error(f'The channel [{channel_name}] is not correct')
|
self._Logs.error(f'The channel [{channel_name}] is not correct')
|
||||||
return None
|
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
|
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
|
return None
|
||||||
|
|
||||||
@@ -713,7 +716,7 @@ class Unrealircd6(IProtocol):
|
|||||||
# HANDLE EVENTS #
|
# 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
|
"""Handle svs2mode coming from a server
|
||||||
>>> [':00BAAAAAG', 'SVS2MODE', '001U01R03', '-r']
|
>>> [':00BAAAAAG', 'SVS2MODE', '001U01R03', '-r']
|
||||||
|
|
||||||
@@ -740,7 +743,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle mode coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -751,7 +754,7 @@ class Unrealircd6(IProtocol):
|
|||||||
|
|
||||||
return None
|
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
|
"""Handle umode2 coming from a server
|
||||||
>>> [':adator_', 'UMODE2', '-i']
|
>>> [':adator_', 'UMODE2', '-i']
|
||||||
|
|
||||||
@@ -778,7 +781,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle quit coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -802,7 +805,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle squit coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -824,7 +827,7 @@ class Unrealircd6(IProtocol):
|
|||||||
|
|
||||||
return None
|
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
|
"""Handle protoctl coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -861,7 +864,7 @@ class Unrealircd6(IProtocol):
|
|||||||
|
|
||||||
return None
|
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
|
"""Handle nick coming from a server
|
||||||
new nickname
|
new nickname
|
||||||
|
|
||||||
@@ -886,7 +889,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle sjoin coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -939,7 +942,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle part coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -957,7 +960,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle EOS coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -998,17 +1001,17 @@ class Unrealircd6(IProtocol):
|
|||||||
self._Logs.info(f"# VERSION : {version} ")
|
self._Logs.info(f"# VERSION : {version} ")
|
||||||
self._Logs.info(f"################################################")
|
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):
|
if self._Base.check_for_new_version(False):
|
||||||
self.send_priv_msg(
|
await self.send_priv_msg(
|
||||||
nick_from=self._Config.SERVICE_NICKNAME,
|
nick_from=self._Config.SERVICE_NICKNAME,
|
||||||
msg=f" New Version available {version}",
|
msg=f" New Version available {version}",
|
||||||
channel=self._Config.SERVICE_CHANLOG
|
channel=self._Config.SERVICE_CHANLOG
|
||||||
)
|
)
|
||||||
|
|
||||||
# Initialisation terminé aprés le premier PING
|
# Initialisation terminé aprés le premier PING
|
||||||
self.send_priv_msg(
|
await self.send_priv_msg(
|
||||||
nick_from=self._Config.SERVICE_NICKNAME,
|
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),
|
msg=tr("[ %sINFORMATION%s ] >> %s is ready!", self._Config.COLORS.green, self._Config.COLORS.nogc, self._Config.SERVICE_NICKNAME),
|
||||||
channel=self._Config.SERVICE_CHANLOG
|
channel=self._Config.SERVICE_CHANLOG
|
||||||
@@ -1020,10 +1023,10 @@ class Unrealircd6(IProtocol):
|
|||||||
module.class_instance.cmd(server_msg_copy)
|
module.class_instance.cmd(server_msg_copy)
|
||||||
|
|
||||||
# Join saved channels & load existing modules
|
# Join saved channels & load existing modules
|
||||||
self._Irc.join_saved_channels()
|
await self._Irc.join_saved_channels()
|
||||||
self._Irc.ModuleUtils.db_load_all_existing_modules(self._Irc)
|
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
|
return None
|
||||||
except IndexError as ie:
|
except IndexError as ie:
|
||||||
@@ -1033,7 +1036,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle REPUTATION coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1064,7 +1067,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle uid message coming from the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1142,15 +1145,15 @@ class Unrealircd6(IProtocol):
|
|||||||
if sasl_obj:
|
if sasl_obj:
|
||||||
if sasl_obj.auth_success:
|
if sasl_obj.auth_success:
|
||||||
self._Irc.insert_db_admin(sasl_obj.client_uid, sasl_obj.username, sasl_obj.level, sasl_obj.language)
|
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),
|
msg=tr("[ %sSASL AUTH%s ] - %s (%s) is now connected successfuly to %s", green, nogc, nickname, sasl_obj.username, dnickname),
|
||||||
channel=dchanlog)
|
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:
|
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),
|
msg=tr("[ %sSASL AUTH%s ] - %s provided a wrong password for this username %s", red, nogc, nickname, sasl_obj.username),
|
||||||
channel=dchanlog)
|
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!
|
# Delete sasl object!
|
||||||
self._Irc.Sasl.delete_sasl_client(uid)
|
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):
|
if self._Irc.Admin.db_auth_admin_via_fingerprint(fingerprint, uid):
|
||||||
admin = self._Irc.Admin.get_admin(uid)
|
admin = self._Irc.Admin.get_admin(uid)
|
||||||
account = admin.account if admin else ''
|
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),
|
msg=tr("[ %sFINGERPRINT AUTH%s ] - %s (%s) is now connected successfuly to %s", green, nogc, nickname, account, dnickname),
|
||||||
channel=dchanlog)
|
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
|
return None
|
||||||
except IndexError as ie:
|
except IndexError as ie:
|
||||||
@@ -1171,7 +1174,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle PRIVMSG message coming from the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1197,7 +1200,7 @@ class Unrealircd6(IProtocol):
|
|||||||
arg.remove(f':{self._Config.SERVICE_PREFIX}')
|
arg.remove(f':{self._Config.SERVICE_PREFIX}')
|
||||||
if not self._Irc.Commands.is_command_exist(arg[0]):
|
if not self._Irc.Commands.is_command_exist(arg[0]):
|
||||||
self._Logs.debug(f"This command {arg[0]} is not available")
|
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_from=self._Config.SERVICE_NICKNAME,
|
||||||
nick_to=user_trigger,
|
nick_to=user_trigger,
|
||||||
msg=f"This command [{self._Config.COLORS.bold}{arg[0]}{self._Config.COLORS.bold}] is not available"
|
msg=f"This command [{self._Config.COLORS.bold}{arg[0]}{self._Config.COLORS.bold}] is not available"
|
||||||
@@ -1208,7 +1211,7 @@ class Unrealircd6(IProtocol):
|
|||||||
self._Base.log_cmd(user_trigger, cmd_to_send)
|
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
|
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:
|
if cmd[2] == self._Config.SERVICE_ID:
|
||||||
pattern = fr'^:.*?:(.*)$'
|
pattern = fr'^:.*?:(.*)$'
|
||||||
@@ -1221,35 +1224,31 @@ class Unrealircd6(IProtocol):
|
|||||||
|
|
||||||
# Réponse a un CTCP VERSION
|
# Réponse a un CTCP VERSION
|
||||||
if arg[0] == '\x01VERSION\x01':
|
if arg[0] == '\x01VERSION\x01':
|
||||||
self.on_version(srv_msg)
|
await self.on_version(srv_msg)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Réponse a un TIME
|
# Réponse a un TIME
|
||||||
if arg[0] == '\x01TIME\x01':
|
if arg[0] == '\x01TIME\x01':
|
||||||
self.on_time(srv_msg)
|
await self.on_time(srv_msg)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Réponse a un PING
|
# Réponse a un PING
|
||||||
if arg[0] == '\x01PING':
|
if arg[0] == '\x01PING':
|
||||||
self.on_ping(srv_msg)
|
await self.on_ping(srv_msg)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not self._Irc.Commands.is_command_exist(arg[0]):
|
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")
|
self._Logs.debug(f"This command {arg[0]} sent by {user_trigger} is not available")
|
||||||
return None
|
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(':','')
|
cmd_to_send = convert_to_string.replace(':','')
|
||||||
self._Base.log_cmd(user_trigger, cmd_to_send)
|
self._Base.log_cmd(user_trigger, cmd_to_send)
|
||||||
|
|
||||||
fromchannel = None
|
fromchannel = None
|
||||||
|
|
||||||
if len(arg) >= 2:
|
if len(arg) >= 2:
|
||||||
fromchannel = str(arg[1]).lower() if self._Irc.Channel.is_valid_channel(arg[1]) else None
|
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
|
return None
|
||||||
|
|
||||||
except KeyError as ke:
|
except KeyError as ke:
|
||||||
@@ -1259,7 +1258,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"General Error: {err} - {srv_msg}" , exc_info=True)
|
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
|
"""Send a PONG message to the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1267,14 +1266,13 @@ class Unrealircd6(IProtocol):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
scopy = server_msg.copy()
|
scopy = server_msg.copy()
|
||||||
pong = str(scopy[1]).replace(':','')
|
await self.send2socket(' '.join(scopy).replace('PING', 'PONG'), print_log=True)
|
||||||
self.send2socket(f"PONG :{pong}", print_log=False)
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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_
|
"""_summary_
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1287,7 +1285,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f'General Error: {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
|
"""Sending Server Version to the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1305,13 +1303,13 @@ class Unrealircd6(IProtocol):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if arg == '\x01VERSION\x01':
|
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
|
return None
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Sending TIME answer to a requestor
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1330,13 +1328,13 @@ class Unrealircd6(IProtocol):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if arg == '\x01TIME\x01':
|
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
|
return None
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Sending a PING answer to requestor
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1360,7 +1358,7 @@ class Unrealircd6(IProtocol):
|
|||||||
ping_response = current_unixtime - recieved_unixtime
|
ping_response = current_unixtime - recieved_unixtime
|
||||||
|
|
||||||
# self._Irc.send2socket(f':{dnickname} NOTICE {nickname} :\x01PING {ping_response} secs\x01')
|
# self._Irc.send2socket(f':{dnickname} NOTICE {nickname} :\x01PING {ping_response} secs\x01')
|
||||||
self.send_notice(
|
await self.send_notice(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
nick_to=nickname,
|
nick_to=nickname,
|
||||||
msg=f"\x01PING {ping_response} secs\x01"
|
msg=f"\x01PING {ping_response} secs\x01"
|
||||||
@@ -1371,7 +1369,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle version coming from the server
|
||||||
\n ex. /version Defender
|
\n ex. /version Defender
|
||||||
Args:
|
Args:
|
||||||
@@ -1389,21 +1387,21 @@ class Unrealircd6(IProtocol):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
response_351 = f"{self._Config.SERVICE_NAME.capitalize()}-{self._Config.CURRENT_VERSION} {self._Config.SERVICE_HOST} {self.name}"
|
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()
|
modules = self._Irc.ModuleUtils.get_all_available_modules()
|
||||||
response_005 = ' | '.join(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)
|
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
|
return None
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f"{__name__} - General Error: {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
|
"""Handle SMOD message coming from the server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1422,7 +1420,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f'General Error: {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
|
"""Handle SASL coming from a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1465,13 +1463,13 @@ class Unrealircd6(IProtocol):
|
|||||||
sasl_obj.mechanisme = str(scopy[5])
|
sasl_obj.mechanisme = str(scopy[5])
|
||||||
|
|
||||||
if sasl_obj.mechanisme == "PLAIN":
|
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":
|
elif sasl_obj.mechanisme == "EXTERNAL":
|
||||||
if str(scopy[5]) == "+":
|
if str(scopy[5]) == "+":
|
||||||
return None
|
return None
|
||||||
|
|
||||||
sasl_obj.fingerprint = str(scopy[6])
|
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)
|
self.on_sasl_authentication_process(sasl_obj)
|
||||||
return sasl_obj
|
return sasl_obj
|
||||||
@@ -1486,18 +1484,18 @@ class Unrealircd6(IProtocol):
|
|||||||
sasl_obj.username = username
|
sasl_obj.username = username
|
||||||
sasl_obj.password = password
|
sasl_obj.password = password
|
||||||
|
|
||||||
self.on_sasl_authentication_process(sasl_obj)
|
await self.on_sasl_authentication_process(sasl_obj)
|
||||||
return sasl_obj
|
return sasl_obj
|
||||||
elif sasl_obj.mechanisme == "EXTERNAL":
|
elif sasl_obj.mechanisme == "EXTERNAL":
|
||||||
sasl_obj.message_type = sasl_message_type
|
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
|
return sasl_obj
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._Logs.error(f'General Error: {err}', exc_info=True)
|
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
|
s = sasl_model
|
||||||
if 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]]:
|
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.auth_success = True
|
||||||
s.level = admin_info.get('level', 0)
|
s.level = admin_info.get('level', 0)
|
||||||
s.language = admin_info.get('language', 'EN')
|
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")
|
await 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} 903 {s.username} :SASL authentication successful")
|
||||||
else:
|
else:
|
||||||
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} 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} 904 {s.username} :SASL authentication failed")
|
||||||
|
|
||||||
elif s.message_type == 'S' and s.mechanisme == 'EXTERNAL':
|
elif s.message_type == 'S' and s.mechanisme == 'EXTERNAL':
|
||||||
# Connection using fingerprints
|
# Connection using fingerprints
|
||||||
@@ -1537,14 +1535,14 @@ class Unrealircd6(IProtocol):
|
|||||||
s.level = admin_info.get('level', 0)
|
s.level = admin_info.get('level', 0)
|
||||||
s.username = admin_info.get('user', None)
|
s.username = admin_info.get('user', None)
|
||||||
s.language = admin_info.get('language', 'EN')
|
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")
|
await 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} 903 {s.username} :SASL authentication successful")
|
||||||
else:
|
else:
|
||||||
# "904 <nick> :SASL authentication failed"
|
# "904 <nick> :SASL authentication failed"
|
||||||
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} 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} 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
|
"""Handle MD responses
|
||||||
[':001', 'MD', 'client', '001MYIZ03', 'certfp', ':d1235648...']
|
[':001', 'MD', 'client', '001MYIZ03', 'certfp', ':d1235648...']
|
||||||
Args:
|
Args:
|
||||||
@@ -1573,7 +1571,7 @@ class Unrealircd6(IProtocol):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._Logs.error(f"General Error: {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
|
"""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']
|
['@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)
|
self._Irc.Channel.delete_user_from_channel(channel, uid)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def on_sethost(self, server_msg: list[str]) -> None:
|
async def on_sethost(self, server_msg: list[str]) -> None:
|
||||||
"""On SETHOST command
|
"""On SETHOST command
|
||||||
>>> [':001DN7305', 'SETHOST', ':netadmin.example.org']
|
>>> [':001DN7305', 'SETHOST', ':netadmin.example.org']
|
||||||
|
|
||||||
|
|||||||
88
core/irc.py
88
core/irc.py
@@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
@@ -26,6 +27,8 @@ class Irc:
|
|||||||
|
|
||||||
def __init__(self, loader: 'Loader'):
|
def __init__(self, loader: 'Loader'):
|
||||||
|
|
||||||
|
self.signal: bool = True
|
||||||
|
|
||||||
# Loader class
|
# Loader class
|
||||||
self.Loader = loader
|
self.Loader = loader
|
||||||
|
|
||||||
@@ -132,8 +135,34 @@ class Irc:
|
|||||||
# Define the IrcSocket object
|
# Define the IrcSocket object
|
||||||
self.IrcSocket: Optional[Union[socket.socket, SSLSocket]] = None
|
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, ))
|
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 #
|
# CONNEXION IRC #
|
||||||
##############################################
|
##############################################
|
||||||
@@ -232,7 +261,7 @@ class Irc:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.Logs.critical(f"General Error: {e}", exc_info=True)
|
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"""
|
"""## Joining saved channels"""
|
||||||
exec_query = self.Base.db_execute_query(f'SELECT distinct channel_name FROM {self.Config.TABLE_CHANNEL}')
|
exec_query = self.Base.db_execute_query(f'SELECT distinct channel_name FROM {self.Config.TABLE_CHANNEL}')
|
||||||
result_query = exec_query.fetchall()
|
result_query = exec_query.fetchall()
|
||||||
@@ -240,25 +269,25 @@ class Irc:
|
|||||||
if result_query:
|
if result_query:
|
||||||
for chan_name in result_query:
|
for chan_name in result_query:
|
||||||
chan = chan_name[0]
|
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:
|
try:
|
||||||
for data in responses:
|
for data in responses:
|
||||||
response = data.decode(self.CHARSET[0]).split()
|
response = data.decode(self.CHARSET[0]).split()
|
||||||
self.cmd(response)
|
await self.cmd(response)
|
||||||
|
|
||||||
except UnicodeEncodeError as ue:
|
except UnicodeEncodeError as ue:
|
||||||
for data in responses:
|
for data in responses:
|
||||||
response = data.decode(self.CHARSET[1],'replace').split()
|
response = data.decode(self.CHARSET[1],'replace').split()
|
||||||
self.cmd(response)
|
await self.cmd(response)
|
||||||
self.Logs.error(f'UnicodeEncodeError: {ue}')
|
self.Logs.error(f'UnicodeEncodeError: {ue}')
|
||||||
self.Logs.error(response)
|
self.Logs.error(response)
|
||||||
|
|
||||||
except UnicodeDecodeError as ud:
|
except UnicodeDecodeError as ud:
|
||||||
for data in responses:
|
for data in responses:
|
||||||
response = data.decode(self.CHARSET[1],'replace').split()
|
response = data.decode(self.CHARSET[1],'replace').split()
|
||||||
self.cmd(response)
|
await self.cmd(response)
|
||||||
self.Logs.error(f'UnicodeDecodeError: {ud}')
|
self.Logs.error(f'UnicodeDecodeError: {ud}')
|
||||||
self.Logs.error(response)
|
self.Logs.error(response)
|
||||||
|
|
||||||
@@ -287,7 +316,7 @@ class Irc:
|
|||||||
|
|
||||||
return None
|
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
|
# Check if the nickname is an admin
|
||||||
p = self.Protocol
|
p = self.Protocol
|
||||||
@@ -300,14 +329,14 @@ class Irc:
|
|||||||
if admin_obj is not None:
|
if admin_obj is not None:
|
||||||
current_level = admin_obj.level
|
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}"
|
header = f" {'Level':<8}| {'Command':<25}| {'Module':<15}| {'Description':<35}"
|
||||||
line = "-"*75
|
line = "-"*75
|
||||||
p.send_notice(nick_from=dnickname,nick_to=nickname, msg=header)
|
await 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=f" {line}")
|
||||||
for cmd in self.Commands.get_commands_by_level(current_level):
|
for cmd in self.Commands.get_commands_by_level(current_level):
|
||||||
if module is None or cmd.module_name.lower() == module.lower():
|
if module is None or cmd.module_name.lower() == module.lower():
|
||||||
p.send_notice(
|
await p.send_notice(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
nick_to=nickname,
|
nick_to=nickname,
|
||||||
msg=f" {color_black}{cmd.command_level:<8}{color_nogc}| {cmd.command_name:<25}| {cmd.module_name:<15}| {cmd.description:<35}"
|
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})")
|
self.Logs.info(f"The nickname {nickname} already exist! (sent by {sender})")
|
||||||
return False
|
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
|
dnickname = self.Config.SERVICE_NICKNAME
|
||||||
|
|
||||||
if self.Base.check_for_new_version(True):
|
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}")
|
await 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=" Please run (git pull origin main) in the current folder")
|
||||||
else:
|
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
|
return None
|
||||||
|
|
||||||
def cmd(self, data: list[str]) -> None:
|
async def cmd(self, data: list[str]) -> None:
|
||||||
"""Parse server response
|
"""Parse server response
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -494,7 +523,7 @@ class Irc:
|
|||||||
|
|
||||||
for parsed in self.Protocol.Handler.get_ircd_commands():
|
for parsed in self.Protocol.Handler.get_ircd_commands():
|
||||||
if parsed.command_name.upper() == parsed_protocol:
|
if parsed.command_name.upper() == parsed_protocol:
|
||||||
parsed.func(original_response)
|
await parsed.func(original_response)
|
||||||
for module in modules:
|
for module in modules:
|
||||||
module.class_instance.cmd(original_response)
|
module.class_instance.cmd(original_response)
|
||||||
|
|
||||||
@@ -509,7 +538,7 @@ class Irc:
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.Logs.error(f"General Error: {err}", exc_info=True)
|
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
|
"""Create
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -560,13 +589,13 @@ class Irc:
|
|||||||
case 'notallowed':
|
case 'notallowed':
|
||||||
try:
|
try:
|
||||||
current_command = str(cmd[0])
|
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),
|
msg=tr('[ %s%s%s ] - Access denied to %s', RED, current_command.upper(), NOGC, fromuser),
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
)
|
)
|
||||||
|
|
||||||
self.Protocol.send_notice(
|
await self.Protocol.send_notice(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
nick_to=fromuser,
|
nick_to=fromuser,
|
||||||
msg=tr('Access denied!')
|
msg=tr('Access denied!')
|
||||||
@@ -1012,7 +1041,7 @@ class Irc:
|
|||||||
case 'help':
|
case 'help':
|
||||||
# Syntax. !help [module_name]
|
# Syntax. !help [module_name]
|
||||||
module_name = str(cmd[1]) if len(cmd) == 2 else None
|
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
|
return None
|
||||||
|
|
||||||
case 'load':
|
case 'load':
|
||||||
@@ -1119,14 +1148,14 @@ class Irc:
|
|||||||
loaded = True
|
loaded = True
|
||||||
|
|
||||||
if loaded:
|
if loaded:
|
||||||
self.Protocol.send_notice(
|
await self.Protocol.send_notice(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
nick_to=fromuser,
|
nick_to=fromuser,
|
||||||
msg=tr('%s - %sLoaded%s by %s on %s', module, GREEN, NOGC, loaded_user, loaded_datetime)
|
msg=tr('%s - %sLoaded%s by %s on %s', module, GREEN, NOGC, loaded_user, loaded_datetime)
|
||||||
)
|
)
|
||||||
loaded = False
|
loaded = False
|
||||||
else:
|
else:
|
||||||
self.Protocol.send_notice(
|
await self.Protocol.send_notice(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
nick_to=fromuser,
|
nick_to=fromuser,
|
||||||
msg=tr('%s - %sNot Loaded%s', module, RED, NOGC)
|
msg=tr('%s - %sNot Loaded%s', module, RED, NOGC)
|
||||||
@@ -1150,11 +1179,17 @@ class Irc:
|
|||||||
|
|
||||||
case 'show_threads':
|
case 'show_threads':
|
||||||
for thread in self.Base.running_threads:
|
for thread in self.Base.running_threads:
|
||||||
self.Protocol.send_notice(
|
await self.Protocol.send_notice(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
nick_to=fromuser,
|
nick_to=fromuser,
|
||||||
msg=f">> {thread.name} ({thread.is_alive()})"
|
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
|
return None
|
||||||
|
|
||||||
case 'show_channels':
|
case 'show_channels':
|
||||||
@@ -1282,3 +1317,8 @@ class Irc:
|
|||||||
|
|
||||||
case _:
|
case _:
|
||||||
pass
|
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.SERVER_PREFIX = None
|
||||||
self.LOGGING_CONSOLE = True
|
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.file_handler = None
|
||||||
self.stdout_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})")
|
self.__Logs.debug(f"[MOD_HEADER ERROR] Impossible to remove the module header ({module_name})")
|
||||||
return False
|
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)
|
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):
|
if self.model_is_module_exist(module_name):
|
||||||
# Si le module existe dans la variable globale retourne False
|
# Si le module existe dans la variable globale retourne False
|
||||||
self.__Logs.debug(f"Module [{module_folder}.{module_name}] exist in the local variable!")
|
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,
|
nick_from=self.__Config.SERVICE_NICKNAME,
|
||||||
msg=f"Le module {module_name} est déja chargé ! si vous souhaiter le recharge tapez {self.__Config.SERVICE_PREFIX}reload {module_name}",
|
msg=f"Le module {module_name} est déja chargé ! si vous souhaiter le recharge tapez {self.__Config.SERVICE_PREFIX}reload {module_name}",
|
||||||
channel=self.__Config.SERVICE_CHANLOG
|
channel=self.__Config.SERVICE_CHANLOG
|
||||||
@@ -110,12 +110,12 @@ class Module:
|
|||||||
try:
|
try:
|
||||||
loaded_module = importlib.import_module(f'mods.{module_folder}.{module_name}')
|
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
|
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)
|
self.create_module_header(create_instance_of_the_class.MOD_HEADER)
|
||||||
except AttributeError as attr:
|
except AttributeError as attr:
|
||||||
red = uplink.Config.COLORS.red
|
red = uplink.Config.COLORS.red
|
||||||
nogc = uplink.Config.COLORS.nogc
|
nogc = uplink.Config.COLORS.nogc
|
||||||
uplink.Protocol.send_priv_msg(
|
await uplink.Protocol.send_priv_msg(
|
||||||
nick_from=self.__Config.SERVICE_NICKNAME,
|
nick_from=self.__Config.SERVICE_NICKNAME,
|
||||||
msg=tr("[%sMODULE ERROR%s] Module %s is facing issues! %s", red, nogc, module_name, attr),
|
msg=tr("[%sMODULE ERROR%s] Module %s is facing issues! %s", red, nogc, module_name, attr),
|
||||||
channel=self.__Config.SERVICE_CHANLOG
|
channel=self.__Config.SERVICE_CHANLOG
|
||||||
@@ -124,7 +124,7 @@ class Module:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if not hasattr(create_instance_of_the_class, 'cmd'):
|
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,
|
nick_from=self.__Config.SERVICE_NICKNAME,
|
||||||
msg=tr("cmd method is not available in the module (%s)", module_name),
|
msg=tr("cmd method is not available in the module (%s)", module_name),
|
||||||
channel=self.__Config.SERVICE_CHANLOG
|
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)):
|
if self.model_insert_module(MModule(module_name, class_name, create_instance_of_the_class)):
|
||||||
# Enregistrer le module dans la base de données
|
# Enregistrer le module dans la base de données
|
||||||
self.db_register_module(module_name, nickname, is_default)
|
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,
|
nick_from=self.__Config.SERVICE_NICKNAME,
|
||||||
msg=tr("Module %s loaded!", module_name),
|
msg=tr("Module %s loaded!", module_name),
|
||||||
channel=self.__Config.SERVICE_CHANLOG
|
channel=self.__Config.SERVICE_CHANLOG
|
||||||
@@ -399,7 +399,7 @@ class Module:
|
|||||||
OPERATION DEDICATED TO DATABASE MANAGEMENT
|
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
|
"""Charge les modules qui existe déja dans la base de données
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@@ -408,7 +408,7 @@ class Module:
|
|||||||
self.__Logs.debug("[DB LOAD MODULE] Loading modules from the database!")
|
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}")
|
result = self.__Base.db_execute_query(f"SELECT module_name FROM {self.__Config.TABLE_MODULE}")
|
||||||
for r in result.fetchall():
|
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
|
return True
|
||||||
|
|
||||||
|
|||||||
27
defender.py
27
defender.py
@@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
from core import install
|
from core import install
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
@@ -9,14 +10,24 @@ from core import install
|
|||||||
# UnrealIRCD 6.2.2 or higher #
|
# UnrealIRCD 6.2.2 or higher #
|
||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
try:
|
async def main():
|
||||||
# install.update_packages()
|
|
||||||
from core.loader import Loader
|
from core.loader import Loader
|
||||||
loader = Loader()
|
loader = Loader()
|
||||||
loader.Irc.init_irc()
|
await loader.Irc.run()
|
||||||
|
|
||||||
except AssertionError as ae:
|
if __name__ == "__main__":
|
||||||
print(f'Assertion Error -> {ae}')
|
asyncio.run(main(), debug=True)
|
||||||
except KeyboardInterrupt as k:
|
|
||||||
# ircInstance.Base.execute_periodic_action()
|
|
||||||
...
|
|
||||||
|
# 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)
|
# self.Base.db_execute_query(table_trusted)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def load(self):
|
async def load(self):
|
||||||
|
|
||||||
# Add module schemas
|
# Add module schemas
|
||||||
self.Schemas = schemas
|
self.Schemas = schemas
|
||||||
@@ -98,8 +98,8 @@ class Defender(IModule):
|
|||||||
self.Base.create_thread(func=thds.thread_autolimit, func_args=(self, ))
|
self.Base.create_thread(func=thds.thread_autolimit, func_args=(self, ))
|
||||||
|
|
||||||
if self.ModConfig.reputation == 1:
|
if self.ModConfig.reputation == 1:
|
||||||
self.Protocol.send_sjoin(self.Config.SALON_JAIL)
|
await 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.send2socket(f":{self.Config.SERVICE_NICKNAME} SAMODE {self.Config.SALON_JAIL} +o {self.Config.SERVICE_NICKNAME}")
|
||||||
|
|
||||||
def __onload(self):
|
def __onload(self):
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ class Defender(IModule):
|
|||||||
exec_query = self.Base.db_execute_query(q_insert, mes_donnees)
|
exec_query = self.Base.db_execute_query(q_insert, mes_donnees)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def join_saved_channels(self) -> None:
|
async def join_saved_channels(self) -> None:
|
||||||
"""_summary_
|
"""_summary_
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
@@ -178,10 +178,10 @@ class Defender(IModule):
|
|||||||
|
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
chan = channel[0]
|
chan = channel[0]
|
||||||
self.Protocol.send_sjoin(chan)
|
await self.Protocol.send_sjoin(chan)
|
||||||
if chan == jail_chan:
|
if chan == jail_chan:
|
||||||
self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} +{dumodes} {dnickname}")
|
await 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} MODE {jail_chan} +{jail_chan_mode}")
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ class Defender(IModule):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.Logs.error(f"General Error: {err}", exc_info=True)
|
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)
|
u = self.User.get_user(user)
|
||||||
if u is None:
|
if u is None:
|
||||||
return None
|
return None
|
||||||
@@ -264,10 +264,10 @@ class Defender(IModule):
|
|||||||
case 'show_reputation':
|
case 'show_reputation':
|
||||||
|
|
||||||
if not self.Reputation.UID_REPUTATION_DB:
|
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:
|
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,
|
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}")
|
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)
|
get_reputation = self.Reputation.get_reputation(jailed_UID)
|
||||||
|
|
||||||
if get_reputation is None:
|
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
|
return False
|
||||||
|
|
||||||
jailed_IP = get_reputation.remote_ip
|
jailed_IP = get_reputation.remote_ip
|
||||||
@@ -293,30 +293,30 @@ class Defender(IModule):
|
|||||||
color_black = self.Config.COLORS.black
|
color_black = self.Config.COLORS.black
|
||||||
|
|
||||||
if release_code == get_reputation.secret_code:
|
if release_code == get_reputation.secret_code:
|
||||||
self.Protocol.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:
|
if self.ModConfig.reputation_ban_all_chan == 1:
|
||||||
for chan in self.Channel.UID_CHANNEL_DB:
|
for chan in self.Channel.UID_CHANNEL_DB:
|
||||||
if chan.name != jailed_salon:
|
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.Reputation.delete(jailed_UID)
|
||||||
self.Logs.debug(f'{jailed_UID} - {jailed_nickname} removed from REPUTATION_DB')
|
self.Logs.debug(f'{jailed_UID} - {jailed_nickname} removed from REPUTATION_DB')
|
||||||
self.Protocol.send_sapart(nick_to_sapart=jailed_nickname, channel_name=jailed_salon)
|
await 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)
|
await 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.send2socket(f":{link} REPUTATION {jailed_IP} {self.ModConfig.reputation_score_after_release}")
|
||||||
u.score_connexion = reputation_seuil + 1
|
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 !",
|
msg=f"[{color_green} MOT DE PASS CORRECT {color_black}] : You have now the right to enjoy the network !",
|
||||||
nick_to=jailed_nickname)
|
nick_to=jailed_nickname)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg="Mauvais password",
|
msg="Mauvais password",
|
||||||
channel=jailed_salon
|
channel=jailed_salon
|
||||||
)
|
)
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[{color_green} MAUVAIS PASSWORD {color_black}] You have typed a wrong code. for recall your password is: {self.Config.SERVICE_PREFIX}code {get_reputation.secret_code}",
|
msg=f"[{color_green} MAUVAIS PASSWORD {color_black}] You have typed a wrong code. for recall your password is: {self.Config.SERVICE_PREFIX}code {get_reputation.secret_code}",
|
||||||
nick_to=jailed_nickname
|
nick_to=jailed_nickname
|
||||||
@@ -324,7 +324,7 @@ class Defender(IModule):
|
|||||||
|
|
||||||
except IndexError as ie:
|
except IndexError as ie:
|
||||||
self.Logs.error(f'Index Error: {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:
|
except KeyError as ke:
|
||||||
self.Logs.error(f'_hcmd code: KeyError {ke}')
|
self.Logs.error(f'_hcmd code: KeyError {ke}')
|
||||||
|
|
||||||
@@ -333,8 +333,8 @@ class Defender(IModule):
|
|||||||
# autolimit on
|
# autolimit on
|
||||||
# autolimit set [amount] [interval]
|
# autolimit set [amount] [interval]
|
||||||
if len(cmd) < 2:
|
if len(cmd) < 2:
|
||||||
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()} 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()} SET [AMOUNT] [INTERVAL]")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
arg = str(cmd[1]).lower()
|
arg = str(cmd[1]).lower()
|
||||||
@@ -345,16 +345,16 @@ class Defender(IModule):
|
|||||||
self.update_configuration('autolimit', 1)
|
self.update_configuration('autolimit', 1)
|
||||||
self.autolimit_isRunning = True
|
self.autolimit_isRunning = True
|
||||||
self.Base.create_thread(func=thds.thread_autolimit, func_args=(self, ))
|
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:
|
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':
|
case 'off':
|
||||||
if self.ModConfig.autolimit == 1:
|
if self.ModConfig.autolimit == 1:
|
||||||
self.update_configuration('autolimit', 0)
|
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:
|
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':
|
case 'set':
|
||||||
amount = int(cmd[2])
|
amount = int(cmd[2])
|
||||||
@@ -362,19 +362,19 @@ class Defender(IModule):
|
|||||||
|
|
||||||
self.update_configuration('autolimit_amount', amount)
|
self.update_configuration('autolimit_amount', amount)
|
||||||
self.update_configuration('autolimit_interval', interval)
|
self.update_configuration('autolimit_interval', interval)
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Amount set to ({amount}) | Interval set to ({interval})",
|
msg=f"[{self.Config.COLORS.green}AUTOLIMIT{self.Config.COLORS.nogc}] Amount set to ({amount}) | Interval set to ({interval})",
|
||||||
channel=self.Config.SERVICE_CHANLOG
|
channel=self.Config.SERVICE_CHANLOG
|
||||||
)
|
)
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
self.Protocol.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()} 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()} SET [AMOUNT] [INTERVAL]")
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
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()} 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()} SET [AMOUNT] [INTERVAL]")
|
||||||
self.Logs.error(f"Value Error -> {err}")
|
self.Logs.error(f"Value Error -> {err}")
|
||||||
|
|
||||||
case 'reputation':
|
case 'reputation':
|
||||||
@@ -396,30 +396,30 @@ class Defender(IModule):
|
|||||||
if activation == 'on':
|
if activation == 'on':
|
||||||
|
|
||||||
if self.ModConfig.reputation == 1:
|
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
|
return False
|
||||||
|
|
||||||
# self.update_db_configuration('reputation', 1)
|
# self.update_db_configuration('reputation', 1)
|
||||||
self.update_configuration(key, 1)
|
self.update_configuration(key, 1)
|
||||||
|
|
||||||
self.Protocol.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)
|
await self.Protocol.send_join_chan(uidornickname=dnickname, channel=jail_chan)
|
||||||
self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} +{dumodes} {dnickname}")
|
await 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} MODE {jail_chan} +{jail_chan_mode}")
|
||||||
|
|
||||||
if self.ModConfig.reputation_sg == 1:
|
if self.ModConfig.reputation_sg == 1:
|
||||||
for chan in self.Channel.UID_CHANNEL_DB:
|
for chan in self.Channel.UID_CHANNEL_DB:
|
||||||
if chan.name != jail_chan:
|
if chan.name != jail_chan:
|
||||||
self.Protocol.send2socket(f":{service_id} MODE {chan.name} +b ~security-group:unknown-users")
|
await 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} +eee ~security-group:webirc-users ~security-group:known-users ~security-group:websocket-users")
|
||||||
|
|
||||||
self.Channel.db_query_channel('add', self.module_name, jail_chan)
|
self.Channel.db_query_channel('add', self.module_name, jail_chan)
|
||||||
|
|
||||||
if activation == 'off':
|
if activation == 'off':
|
||||||
|
|
||||||
if self.ModConfig.reputation == 0:
|
if self.ModConfig.reputation == 0:
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Already deactivated",
|
msg=f"[ {self.Config.COLORS.green}REPUTATION{self.Config.COLORS.black} ] : Already deactivated",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
@@ -428,19 +428,19 @@ class Defender(IModule):
|
|||||||
|
|
||||||
self.update_configuration(key, 0)
|
self.update_configuration(key, 0)
|
||||||
|
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.red}REPUTATION{self.Config.COLORS.black} ] : Deactivated by {fromuser}",
|
msg=f"[ {self.Config.COLORS.red}REPUTATION{self.Config.COLORS.black} ] : Deactivated by {fromuser}",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
)
|
)
|
||||||
self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} -{dumodes} {dnickname}")
|
await self.Protocol.send2socket(f":{service_id} SAMODE {jail_chan} -{dumodes} {dnickname}")
|
||||||
self.Protocol.send2socket(f":{service_id} MODE {jail_chan} -sS")
|
await 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} PART {jail_chan}")
|
||||||
|
|
||||||
for chan in self.Channel.UID_CHANNEL_DB:
|
for chan in self.Channel.UID_CHANNEL_DB:
|
||||||
if chan.name != jail_chan:
|
if chan.name != jail_chan:
|
||||||
self.Protocol.send2socket(f":{service_id} MODE {chan.name} -b ~security-group:unknown-users")
|
await 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} -eee ~security-group:webirc-users ~security-group:known-users ~security-group:websocket-users")
|
||||||
|
|
||||||
self.Channel.db_query_channel('del', self.module_name, jail_chan)
|
self.Channel.db_query_channel('del', self.module_name, jail_chan)
|
||||||
|
|
||||||
@@ -450,7 +450,7 @@ class Defender(IModule):
|
|||||||
match get_options:
|
match get_options:
|
||||||
case 'release':
|
case 'release':
|
||||||
# .reputation release [nick]
|
# .reputation release [nick]
|
||||||
p = self.Protocol
|
p = await self.Protocol
|
||||||
link = self.Config.SERVEUR_LINK
|
link = self.Config.SERVEUR_LINK
|
||||||
jailed_salon = self.Config.SALON_JAIL
|
jailed_salon = self.Config.SALON_JAIL
|
||||||
welcome_salon = self.Config.SALON_LIBERER
|
welcome_salon = self.Config.SALON_LIBERER
|
||||||
@@ -507,7 +507,7 @@ class Defender(IModule):
|
|||||||
if get_value == 'on':
|
if get_value == 'on':
|
||||||
|
|
||||||
if self.ModConfig.reputation_ban_all_chan == 1:
|
if self.ModConfig.reputation_ban_all_chan == 1:
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already activated",
|
msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already activated",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
@@ -517,7 +517,7 @@ class Defender(IModule):
|
|||||||
# self.update_db_configuration(key, 1)
|
# self.update_db_configuration(key, 1)
|
||||||
self.update_configuration(key, 1)
|
self.update_configuration(key, 1)
|
||||||
|
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Activated by {fromuser}",
|
msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Activated by {fromuser}",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
@@ -525,7 +525,7 @@ class Defender(IModule):
|
|||||||
|
|
||||||
elif get_value == 'off':
|
elif get_value == 'off':
|
||||||
if self.ModConfig.reputation_ban_all_chan == 0:
|
if self.ModConfig.reputation_ban_all_chan == 0:
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already deactivated",
|
msg=f"[ {self.Config.COLORS.red}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Already deactivated",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
@@ -535,7 +535,7 @@ class Defender(IModule):
|
|||||||
# self.update_db_configuration(key, 0)
|
# self.update_db_configuration(key, 0)
|
||||||
self.update_configuration(key, 0)
|
self.update_configuration(key, 0)
|
||||||
|
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Deactivated by {fromuser}",
|
msg=f"[ {self.Config.COLORS.green}BAN ON ALL CHANS{self.Config.COLORS.black} ] : Deactivated by {fromuser}",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
@@ -548,71 +548,71 @@ class Defender(IModule):
|
|||||||
# self.update_db_configuration(key, reputation_seuil)
|
# self.update_db_configuration(key, reputation_seuil)
|
||||||
self.update_configuration(key, reputation_seuil)
|
self.update_configuration(key, reputation_seuil)
|
||||||
|
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.green}REPUTATION SEUIL{self.Config.COLORS.black} ] : Limit set to {str(reputation_seuil)} by {fromuser}",
|
msg=f"[ {self.Config.COLORS.green}REPUTATION SEUIL{self.Config.COLORS.black} ] : Limit set to {str(reputation_seuil)} by {fromuser}",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
)
|
)
|
||||||
self.Protocol.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':
|
case 'timer':
|
||||||
reputation_timer = int(cmd[3])
|
reputation_timer = int(cmd[3])
|
||||||
key = 'reputation_timer'
|
key = 'reputation_timer'
|
||||||
self.update_configuration(key, reputation_timer)
|
self.update_configuration(key, reputation_timer)
|
||||||
|
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.green}REPUTATION TIMER{self.Config.COLORS.black} ] : Timer set to {str(reputation_timer)} minute(s) by {fromuser}",
|
msg=f"[ {self.Config.COLORS.green}REPUTATION TIMER{self.Config.COLORS.black} ] : Timer set to {str(reputation_timer)} minute(s) by {fromuser}",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
)
|
)
|
||||||
self.Protocol.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':
|
case 'score_after_release':
|
||||||
reputation_score_after_release = int(cmd[3])
|
reputation_score_after_release = int(cmd[3])
|
||||||
key = 'reputation_score_after_release'
|
key = 'reputation_score_after_release'
|
||||||
self.update_configuration(key, reputation_score_after_release)
|
self.update_configuration(key, reputation_score_after_release)
|
||||||
|
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.green}REPUTATION SCORE AFTER RELEASE{self.Config.COLORS.black} ] : Reputation score after release set to {str(reputation_score_after_release)} by {fromuser}",
|
msg=f"[ {self.Config.COLORS.green}REPUTATION SCORE AFTER RELEASE{self.Config.COLORS.black} ] : Reputation score after release set to {str(reputation_score_after_release)} by {fromuser}",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
)
|
)
|
||||||
self.Protocol.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':
|
case 'security_group':
|
||||||
reputation_sg = int(cmd[3])
|
reputation_sg = int(cmd[3])
|
||||||
key = 'reputation_sg'
|
key = 'reputation_sg'
|
||||||
self.update_configuration(key, reputation_sg)
|
self.update_configuration(key, reputation_sg)
|
||||||
|
|
||||||
self.Protocol.send_priv_msg(
|
await self.Protocol.send_priv_msg(
|
||||||
nick_from=dnickname,
|
nick_from=dnickname,
|
||||||
msg=f"[ {self.Config.COLORS.green}REPUTATION SECURITY-GROUP{self.Config.COLORS.black} ] : Reputation Security-group set to {str(reputation_sg)} by {fromuser}",
|
msg=f"[ {self.Config.COLORS.green}REPUTATION SECURITY-GROUP{self.Config.COLORS.black} ] : Reputation Security-group set to {str(reputation_sg)} by {fromuser}",
|
||||||
channel=dchanlog
|
channel=dchanlog
|
||||||
)
|
)
|
||||||
self.Protocol.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 _:
|
case _:
|
||||||
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 [ON/OFF]")
|
||||||
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 release [nickname]")
|
||||||
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 banallchan [ON/OFF]")
|
||||||
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 limit [1234]")
|
||||||
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 score_after_release [1234]")
|
||||||
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 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 set action [kill|None]")
|
||||||
|
|
||||||
except IndexError as ie:
|
except IndexError as ie:
|
||||||
self.Logs.warning(f'{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]")
|
await 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]")
|
await 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]")
|
await 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]")
|
await 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]")
|
await 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]")
|
await 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 set action [kill|None]")
|
||||||
|
|
||||||
except ValueError as ve:
|
except ValueError as ve:
|
||||||
self.Logs.warning(f'{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':
|
case 'proxy_scan':
|
||||||
|
|
||||||
@@ -628,11 +628,11 @@ class Defender(IModule):
|
|||||||
set_key = str(cmd[1]).lower()
|
set_key = str(cmd[1]).lower()
|
||||||
|
|
||||||
if set_key != 'set':
|
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]')
|
await 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]')
|
await 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]')
|
await 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]')
|
await 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 cloudfilt_scan [ON/OFF]')
|
||||||
|
|
||||||
option = str(cmd[2]).lower() # => local_scan, psutil_scan, abuseipdb_scan
|
option = str(cmd[2]).lower() # => local_scan, psutil_scan, abuseipdb_scan
|
||||||
action = str(cmd[3]).lower() # => on / off
|
action = str(cmd[3]).lower() # => on / off
|
||||||
@@ -641,105 +641,105 @@ class Defender(IModule):
|
|||||||
case 'local_scan':
|
case 'local_scan':
|
||||||
if action == 'on':
|
if action == 'on':
|
||||||
if self.ModConfig.local_scan == 1:
|
if self.ModConfig.local_scan == 1:
|
||||||
self.Protocol.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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 1)
|
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':
|
elif action == 'off':
|
||||||
if self.ModConfig.local_scan == 0:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 0)
|
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':
|
case 'psutil_scan':
|
||||||
if action == 'on':
|
if action == 'on':
|
||||||
if self.ModConfig.psutil_scan == 1:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 1)
|
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':
|
elif action == 'off':
|
||||||
if self.ModConfig.psutil_scan == 0:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 0)
|
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':
|
case 'abuseipdb_scan':
|
||||||
if action == 'on':
|
if action == 'on':
|
||||||
if self.ModConfig.abuseipdb_scan == 1:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 1)
|
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':
|
elif action == 'off':
|
||||||
if self.ModConfig.abuseipdb_scan == 0:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 0)
|
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':
|
case 'freeipapi_scan':
|
||||||
if action == 'on':
|
if action == 'on':
|
||||||
if self.ModConfig.freeipapi_scan == 1:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 1)
|
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':
|
elif action == 'off':
|
||||||
if self.ModConfig.freeipapi_scan == 0:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 0)
|
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':
|
case 'cloudfilt_scan':
|
||||||
if action == 'on':
|
if action == 'on':
|
||||||
if self.ModConfig.cloudfilt_scan == 1:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 1)
|
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':
|
elif action == 'off':
|
||||||
if self.ModConfig.cloudfilt_scan == 0:
|
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
|
return None
|
||||||
|
|
||||||
self.update_configuration(option, 0)
|
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 _:
|
case _:
|
||||||
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 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]')
|
await 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]')
|
await 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]')
|
await 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 cloudfilt_scan [ON/OFF]')
|
||||||
else:
|
else:
|
||||||
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 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]')
|
await 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]')
|
await 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]')
|
await 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 cloudfilt_scan [ON/OFF]')
|
||||||
|
|
||||||
case 'flood':
|
case 'flood':
|
||||||
# .flood on/off
|
# .flood on/off
|
||||||
@@ -754,21 +754,21 @@ class Defender(IModule):
|
|||||||
key = 'flood'
|
key = 'flood'
|
||||||
if activation == 'on':
|
if activation == 'on':
|
||||||
if self.ModConfig.flood == 1:
|
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
|
return False
|
||||||
|
|
||||||
self.update_configuration(key, 1)
|
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 activation == 'off':
|
||||||
if self.ModConfig.flood == 0:
|
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
|
return False
|
||||||
|
|
||||||
self.update_configuration(key, 0)
|
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:
|
if len_cmd == 4:
|
||||||
set_key = str(cmd[2]).lower()
|
set_key = str(cmd[2]).lower()
|
||||||
@@ -780,7 +780,7 @@ class Defender(IModule):
|
|||||||
set_value = int(cmd[3])
|
set_value = int(cmd[3])
|
||||||
self.update_configuration(key, set_value)
|
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}",
|
msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood message set to {set_value} by {fromuser}",
|
||||||
channel=dchanlog)
|
channel=dchanlog)
|
||||||
|
|
||||||
@@ -789,7 +789,7 @@ class Defender(IModule):
|
|||||||
set_value = int(cmd[3])
|
set_value = int(cmd[3])
|
||||||
self.update_configuration(key, set_value)
|
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}",
|
msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood time set to {set_value} by {fromuser}",
|
||||||
channel=dchanlog)
|
channel=dchanlog)
|
||||||
|
|
||||||
@@ -798,7 +798,7 @@ class Defender(IModule):
|
|||||||
set_value = int(cmd[3])
|
set_value = int(cmd[3])
|
||||||
self.update_configuration(key, set_value)
|
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}",
|
msg=f"[ {self.Config.COLORS.green}FLOOD{self.Config.COLORS.black} ] : Flood timer set to {set_value} by {fromuser}",
|
||||||
channel=dchanlog)
|
channel=dchanlog)
|
||||||
|
|
||||||
@@ -814,33 +814,33 @@ class Defender(IModule):
|
|||||||
color_black = self.Config.COLORS.black
|
color_black = self.Config.COLORS.black
|
||||||
nogc = self.Config.COLORS.nogc
|
nogc = self.Config.COLORS.nogc
|
||||||
try:
|
try:
|
||||||
self.Protocol.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' [{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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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]')
|
await 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}')
|
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}')
|
||||||
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.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}')
|
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}')
|
||||||
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.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}')
|
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}')
|
||||||
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{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}')
|
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}')
|
||||||
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.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}')
|
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}')
|
||||||
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=' flood_action ==> Coming soon')
|
||||||
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_message ==> {self.ModConfig.flood_message}')
|
||||||
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_time ==> {self.ModConfig.flood_time}')
|
||||||
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' 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.flood == 1 else color_red}Sentinel{nogc}] ==> {self.ModConfig.sentinel}')
|
||||||
except KeyError as ke:
|
except KeyError as ke:
|
||||||
self.Logs.error(f"Key Error : {ke}")
|
self.Logs.error(f"Key Error : {ke}")
|
||||||
|
|
||||||
case 'info':
|
case 'info':
|
||||||
try:
|
try:
|
||||||
if len(cmd) < 2:
|
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
|
return None
|
||||||
|
|
||||||
nickoruid = cmd[1]
|
nickoruid = cmd[1]
|
||||||
@@ -849,22 +849,22 @@ class Defender(IModule):
|
|||||||
if UserObject is not None:
|
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]
|
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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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}')
|
await 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)}')
|
await 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' CONNECTION TIME : {UserObject.connexion_datetime}')
|
||||||
else:
|
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:
|
except KeyError as ke:
|
||||||
self.Logs.warning(f"Key error info user : {ke}")
|
self.Logs.warning(f"Key error info user : {ke}")
|
||||||
@@ -883,8 +883,8 @@ class Defender(IModule):
|
|||||||
self.update_configuration('sentinel', 1)
|
self.update_configuration('sentinel', 1)
|
||||||
for chan in self.Channel.UID_CHANNEL_DB:
|
for chan in self.Channel.UID_CHANNEL_DB:
|
||||||
if chan.name not in channel_to_dont_quit:
|
if chan.name not in channel_to_dont_quit:
|
||||||
self.Protocol.send_join_chan(uidornickname=dnickname, channel=chan.name)
|
await 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_priv_msg(dnickname, f"Sentinel mode activated on {channel}", channel=chan.name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if activation == 'off':
|
if activation == 'off':
|
||||||
@@ -895,7 +895,7 @@ class Defender(IModule):
|
|||||||
self.update_configuration('sentinel', 0)
|
self.update_configuration('sentinel', 0)
|
||||||
for chan in self.Channel.UID_CHANNEL_DB:
|
for chan in self.Channel.UID_CHANNEL_DB:
|
||||||
if chan.name not in channel_to_dont_quit:
|
if chan.name not in channel_to_dont_quit:
|
||||||
self.Protocol.send_part_chan(uidornickname=dnickname, channel=chan.name)
|
await 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_priv_msg(dnickname, f"Sentinel mode deactivated on {channel}", channel=chan.name)
|
||||||
self.join_saved_channels()
|
self.join_saved_channels()
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ def delete_vote_channel_from_database(uplink: 'Votekick', channel: str) -> bool:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def join_saved_channels(uplink: 'Votekick') -> None:
|
async def join_saved_channels(uplink: 'Votekick') -> None:
|
||||||
|
|
||||||
param = {'module_name': uplink.module_name}
|
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)
|
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:
|
for channel in channels:
|
||||||
id_, chan = channel
|
id_, chan = channel
|
||||||
uplink.VoteKickManager.activate_new_channel(chan)
|
uplink.VoteKickManager.activate_new_channel(chan)
|
||||||
uplink.Protocol.send_sjoin(channel=chan)
|
await uplink.Protocol.send_sjoin(channel=chan)
|
||||||
uplink.Protocol.send2socket(f":{uplink.Config.SERVICE_NICKNAME} SAMODE {chan} +o {uplink.Config.SERVICE_NICKNAME}")
|
await uplink.Protocol.send2socket(f":{uplink.Config.SERVICE_NICKNAME} SAMODE {chan} +o {uplink.Config.SERVICE_NICKNAME}")
|
||||||
|
|
||||||
return None
|
return None
|
||||||
Reference in New Issue
Block a user