Update modules/ban_engine.py

This commit is contained in:
Nova Cat 2025-01-10 18:54:51 -08:00
parent efff8c0904
commit d525b4a91e

View file

@ -12,26 +12,29 @@ class IRCatModule:
self.useSQLengine = True
self.SQLengine = sql
def onValidate(self, socket, ip):
print("IP is banned, killing connection now...")
reason = " ".join(i.split(" ")[1:])
host = self.host
socket.sendall(bytes(f":{host} 465 * :You are banned from this server\r\n","UTF-8"))
socket.sendall(bytes(f"ERROR :Closing Link: {ip} (K-Lined: {reason})\r\n","UTF-8"))
raise Exception("K-Lined: " + " ".join(i.split(" ")[1:]))
def onSocket(self, socket, value, ip, cachedNick=None):
if self.useSQLengine:
pass
else:
bans = open(self.ban_provider).read().split("\n")
for i in bans:
if ip in i.split(" ")[0]:
print("IP is banned, killing connection now...")
reason = " ".join(i.split(" ")[1:])
host = self.host
socket.sendall(bytes(f":{host} 465 * :You are banned from this server\r\n","UTF-8"))
socket.sendall(bytes(f"ERROR :Closing Link: {ip} (K-Lined: {reason})\r\n","UTF-8"))
raise Exception("Banned: " + " ".join(i.split(" ")[1:]))
pass
bans = open(self.ban_provider).read().split("\n")
for i in bans:
if ip in i.split(" ")[0]:
print("IP is banned, killing connection now...")
reason = " ".join(i.split(" ")[1:])
host = self.host
socket.sendall(bytes(f":{host} 465 * :You are banned from this server\r\n","UTF-8"))
socket.sendall(bytes(f"ERROR :Closing Link: {ip} (K-Lined: {reason})\r\n","UTF-8"))
raise Exception("K-Lined: " + " ".join(i.split(" ")[1:]))
def onSocket(self, socket, value, ip, cachedNick=None, validated=False):
if validated:
if self.useSQLengine:
pass
else:
bans = open(self.ban_provider).read().split("\n")
for i in bans:
if ip in i.split(" ")[0]:
print("IP is banned, killing connection now...")
reason = " ".join(i.split(" ")[1:])
host = self.host
socket.sendall(bytes(f":{host} 465 * :You are banned from this server\r\n","UTF-8"))
socket.sendall(bytes(f"ERROR :Closing Link: {ip} (K-Lined: {reason})\r\n","UTF-8"))
raise Exception("Banned: " + " ".join(i.split(" ")[1:]))
def ban(self, target_mask, reason="The ban() hammer has spoken!"):
if self.useSQLengine:
cur = self.SQLengine.conn.cursor()