tBKwtWS 7 rokov pred
rodič
commit
f8c8b06c0a
2 zmenil súbory, kde vykonal 38 pridanie a 2 odobranie
  1. 34 2
      irc/commands/admin.py
  2. 4 0
      irc/common/do_everything_to.py

+ 34 - 2
irc/commands/admin.py

@@ -1,4 +1,4 @@
-import secrets, string
+import secrets, string, re
 from common import userstatus, do_everything_to
 from commands.common import CommandHelpers as CH
 from commands.common import AdminHelpers as AH
@@ -55,7 +55,7 @@ def do_command(self, connection, event):
             if CH.ccc(self, "registernick",  {"homechan": "owner",  "chan": None}, event):
                 message += CH.ccc(self, "registernick",  {"homechan": "owner",  "chan": None}, event)
             if CH.ccc(self, "banall",  {"homechan": "admin",  "chan": None}, event):
-                message += CH.ccc(self, "msg",  {"homechan": "oper",  "chan": "oper"}, event)
+                message += CH.ccc(self, "banall",  {"homechan": "oper",  "chan": "oper"}, event)
             if CH.ccc(self, "msg",  {"homechan": "oper",  "chan": "oper"}, event):
                 message += CH.ccc(self, "msg",  {"homechan": "oper",  "chan": "oper"}, event)
             if CH.ccc(self, "act", {"homechan": "oper",  "chan": "oper"}, event):
@@ -327,3 +327,35 @@ def do_command(self, connection, event):
                 connection.privmsg("NickServ", "REGISTER " + password + " " + trigger.split()[1])
             else:
                 connection.privmsg("NickServ", "REGISTER " + self.db.one("SELECT password FROM networks WHERE name='" + self.network + "'") + " " + trigger.split()[1])
+    
+    elif command.split()[0] == "banall":
+        if not self.channels[self.homechannel].is_owner(event.source.nick): #Insufficient rights.
+            connection.privmsg(replyto, "Denied, you need to be the owner of " + red + self.homechannel  + reset + ".")
+            return
+        if cmdtype == "help":    # Display help text.
+            if len(command.split()) is not 1:
+                return
+            connection.privmsg(replyto, "Ban all nicknames and usernames for a host in all channels.")
+            connection.privmsg(replyto, grey + "Example: " + blue + self.cmdchar + "banall " + reset + italic + "host")
+        elif cmdtype == "cmd":
+            
+            if len(command.split()) == 1:
+                connection.privmsg(replyto, "Insufficient arguments. For help type " + blue + self.helpchar + "banall" + reset + ".")
+            elif len(command.split()) > 2:
+                connection.privmsg(replyto, "Too many arguments. For help type " + blue + self.helpchar + "banall" + reset + ".")
+            else:
+                labels = trigger.split()[1].split(".")
+                allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
+                if "!" in trigger.split()[1] or "@" in trigger.split()[1]:
+                    connection.privmsg(replyto, "Only supply the host, all nicknames and usernames will be banned.")
+                elif len(trigger.split()[1]) > 253:
+                    connection.privmsg(replyto, "Host is to long.")    
+                elif re.match(r"[0-9]+$", labels[-1]):
+                    connection.privmsg(replyto, "The toplevel domain can not containof only numbers.")
+                elif not all(allowed.match(label) for label in labels):
+                    connection.privmsg(replyto, "Host contains invalid characters.")
+                elif len(labels) < 2:
+                    connection.privmsg(replyto, "Insufficient tuples.")
+                else:
+                    for channel in self.channels:
+                        connection.mode(channel, "+b *!*@" + trigger.split()[0])

+ 4 - 0
irc/common/do_everything_to.py

@@ -25,6 +25,10 @@ def ban(connection, channel, user, mask, reason):
     ChanServ.ban(connection, channel, user, reason)
     connection.mode(channel, "+b " + mask)
 
+def banhost(connection, channel, mask, reason):
+    ChanServ.ban(connection, channel, mask, reason)
+    connection.mode(channel, "+b " + mask)
+
 def kick(connection, channel, user, reason):
     ChanServ.kick(connection, channel, user, reason)
     connection.kick(channel, user, reason)