Przeglądaj źródła

improved message filter

tBKwtWS 7 lat temu
rodzic
commit
4df7d0c6b9
1 zmienionych plików z 17 dodań i 23 usunięć
  1. 17 23
      irc/bot.py

+ 17 - 23
irc/bot.py

@@ -123,15 +123,6 @@ class PyRot(irc.bot.SingleServerIRCBot):
         commands.statistics.do_command(self, connection, event)
         commands.games.do_command(self, connection, event)
         if not event.source.nick == connection.get_nickname():
-            if event.source.nick == "NickServ":
-                if event.arguments[0] == event.arguments[0] == "You are already identified.":
-                    return
-            if event.source.nick == "ChanServ":
-                if event.arguments[0] == "Password authentication required for that command." or event.arguments[0] == "You have been unbanned from 0 channels." or event.arguments[0].startswith("You have been unbanned from") or event.arguemnts[0].endswith("autokick list is empty.") or event.arguments[0].startswith("You are already in"):
-                    return
-                if event.arguemnts[0].startswith("Channel ") and event.arguments[0].endswith(" has no key."):
-                    return
-                    
             Inform.owners(self, connection, "PM from " + red + red + event.source.nick + grey + ": " + reset + event.arguments[0])
     
     def on_pubnotice(self, connection, event):
@@ -150,22 +141,25 @@ class PyRot(irc.bot.SingleServerIRCBot):
         commands.statistics.do_command(self, connection, event)
         commands.games.do_command(self, connection, event)
         try:
-            if event.source.nick == "NickServ" and event.arguments[0].startswith("This nickname is registered"):
-                connection.privmsg("NickServ", "identify " + connection.nickname + " " + self.password) # Identify with NickServ.
-            if event.source.nick == "ChanServ" and event.arguments[0].startswith("Key for channel ") and len(event.arguments[0]) > 5:   # Received channel key.
-                connection.join(event.arguments[0].split(' ')[3], event.arguments[0].split(' ')[5][:-1])
+            if event.source.nick == "NickServ":
+                if event.arguments[0].startswith("This nickname is registered"):
+                    connection.privmsg("NickServ", "identify " + connection.nickname + " " + self.password) # Identify with NickServ.
+                    return
+                if event.arguments[0] == "You are already identified.":
+                    return
+            elif event.source.nick == "ChanServ":
+                if event.arguments[0].startswith("Key for channel ") and len(event.arguments[0]) > 5:   # Received channel key.
+                    connection.join(event.arguments[0].split(' ')[3], event.arguments[0].split(' ')[5][:-1])
+                if event.arguments[0] == "Password authentication required for that command.":  # Not authenticated with NisckServ.
+                    Inform.owners(self, connection, "Not authenticated with NickServ. See " + blue + self.helpchar + "recovernick " + reset + "and " + blue + self.helpchar + "registernick" + reset + ".")
+                    return
+                if event.arguments[0].startswith("You have been unbanned from ") or event.arguments[0].endswith(" autokick list is empty.") or event.arguments[0].startswith("You are already in "):
+                    return
+                if event.arguments[0].startswith("Channel ") and event.arguments[0].endswith(" has no key."):
+                    return
+            Inform.owners(self, connection, "Notice from " + red + red + event.source.nick + grey + ": " + reset + event.arguments[0])
         except:
             pass
-        try:
-            if event.source.nick == "ChanServ" and event.arguments[0] == "Password authentication required for that command.":  # Not authenticated with NisckServ.
-                Inform.owners(self, connection, "Not authenticated with NickServ. See " + blue + self.helpchar + "recovernick " + reset + "and " + blue + self.helpchar + "registernick" + reset + ".")
-                return
-            
-            #default = forward to owners.
-            else:
-                Inform.owners(self, connection, "Notice from " + red + red + event.source.nick + grey + ": " + reset + event.arguments[0] + ".")
-        except:
-            return
     
     def on_action(self, connection, event):
         events.on_action.process_event(self, connection, event)