Explorar el Código

mode crash fix

tBKwtWS hace 7 años
padre
commit
31ed3584ad
Se han modificado 1 ficheros con 44 adiciones y 41 borrados
  1. 44 41
      events/on_mode.py

+ 44 - 41
events/on_mode.py

@@ -61,44 +61,47 @@ def process_event(self, connection, event):
             if userstatus.atleast_halfop(self, event.source.nick, self.homechannel) and not self.channels[self.homechannel].is_owner(protectee):
                 return
             
-            if behaviour == "passive":    # Passive behaviour.
-                return
-            elif behaviour == "defense_only":   # Defensive only behaviour.
-                if mode[1] == "b" and mode[0] == "+":  # Ban.
-                    #for protectee in self.protectees:
-                    if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]):  # Protectee.
-                        do_everything_to.unban(connection, event.target, protectee, mode[2])
-                elif mode[1] == "e" and mode[0] == "-":  # Removed exception.
-                    #for protectee in self.protectees:
-                    if fnmatch.fnmatch(self.protectees[protectee]['ident'], event.arguments[idx + 1]):  # Protectee.
-                        connection.mode(event.target, "+e " + mode[2])
-            elif behaviour == "equal_retalliation":   # Equal retaliatory behaviour.
-                if modes[1] == "b" and mode[0] == "+":  # Ban.
-                    #for protectee in self.protectees:
-                    if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]):  # Protectee.
-                        do_everything_to.unban(connection, event.target, protectee, mode[2])
-                        if protectee == connection.get_nickname():  # Bot banned.
-                            ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = equal_retalliation.")
-                        else:
-                            ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = equal_retalliation: " + protectee + " is an operator of " + connection.get_nickname() + ".")
-                        connection.mode(event.target, "+b " + event.source)
-                elif mode[1] == "e" and mode[0] == "-":  # Removed exception.
-                    #for protectee in self.protectees:
-                    if fnmatch.fnmatch(self.protectees[protectee]['ident'], event.arguments[idx + 1]):  # Protectee.
-                        connection.mode(event.target, "+e " + event.arguments[idx + 1])
-            elif behaviour == "battlebot":  # Battlebot behaviour.
-                if mode[1] == "b" and mode[0] == "+":  # Ban.
-                    #for protectee in self.protectees:
-                    if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]):  # Protectee.
-                        do_everything_to.unban(connection, event.target, protectee, mode[2])
-                        do_everything_to.ban(connection, event.target, event.source.nick, event.source, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
-                        connection.mode(event.target, "+e " + mode[2])
-                        ChanServ.akick_add(connection, event.target, event.source.nick)
-                        do_everything_to.kick(connection, event.target, event.source.nick, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
-                elif mode[1] == "e" and mode[0] == "-":  # Removed exception.
-                    #for protectee in self.protectees:
-                    if fnmatch.fnmatch(self.protectees[protectee]['ident'], event.arguments[idx + 1]):  # Protectee.
-                        do_everything_to.ban(connection, event.target, event.source.nick, event.source, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
-                        connection.mode(event.target, "+e " + event.arguments[idx + 1])
-                        ChanServ.akick_add(connection, event.target, event.source.nick)
-                        do_everything_to.kick(connection, event.target, event.source.nick, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
+            try:    # Had "IndexError: list index out of range" on "if modes[1] == "b" and mode[0] == "+":  # Ban.".
+                if behaviour == "passive":    # Passive behaviour.
+                    return
+                elif behaviour == "defense_only":   # Defensive only behaviour.
+                    if mode[1] == "b" and mode[0] == "+":  # Ban.
+                        #for protectee in self.protectees:
+                        if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]):  # Protectee.
+                            do_everything_to.unban(connection, event.target, protectee, mode[2])
+                    elif mode[1] == "e" and mode[0] == "-":  # Removed exception.
+                        #for protectee in self.protectees:
+                        if fnmatch.fnmatch(self.protectees[protectee]['ident'], event.arguments[idx + 1]):  # Protectee.
+                            connection.mode(event.target, "+e " + mode[2])
+                elif behaviour == "equal_retalliation":   # Equal retaliatory behaviour.
+                    if modes[1] == "b" and mode[0] == "+":  # Ban.
+                        #for protectee in self.protectees:
+                        if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]):  # Protectee.
+                            do_everything_to.unban(connection, event.target, protectee, mode[2])
+                            if protectee == connection.get_nickname():  # Bot banned.
+                                ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = equal_retalliation.")
+                            else:
+                                ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = equal_retalliation: " + protectee + " is an operator of " + connection.get_nickname() + ".")
+                            connection.mode(event.target, "+b " + event.source)
+                    elif mode[1] == "e" and mode[0] == "-":  # Removed exception.
+                        #for protectee in self.protectees:
+                        if fnmatch.fnmatch(self.protectees[protectee]['ident'], event.arguments[idx + 1]):  # Protectee.
+                            connection.mode(event.target, "+e " + event.arguments[idx + 1])
+                elif behaviour == "battlebot":  # Battlebot behaviour.
+                    if mode[1] == "b" and mode[0] == "+":  # Ban.
+                        #for protectee in self.protectees:
+                        if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]):  # Protectee.
+                            do_everything_to.unban(connection, event.target, protectee, mode[2])
+                            do_everything_to.ban(connection, event.target, event.source.nick, event.source, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
+                            connection.mode(event.target, "+e " + mode[2])
+                            ChanServ.akick_add(connection, event.target, event.source.nick)
+                            do_everything_to.kick(connection, event.target, event.source.nick, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
+                    elif mode[1] == "e" and mode[0] == "-":  # Removed exception.
+                        #for protectee in self.protectees:
+                        if fnmatch.fnmatch(self.protectees[protectee]['ident'], event.arguments[idx + 1]):  # Protectee.
+                            do_everything_to.ban(connection, event.target, event.source.nick, event.source, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
+                            connection.mode(event.target, "+e " + event.arguments[idx + 1])
+                            ChanServ.akick_add(connection, event.target, event.source.nick)
+                            do_everything_to.kick(connection, event.target, event.source.nick, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
+            except:
+                pass