Selaa lähdekoodia

slapguard/replyto.name logic

tBKwtWS 7 vuotta sitten
vanhempi
sitoutus
660315cb67
1 muutettua tiedostoa jossa 14 lisäystä ja 14 poistoa
  1. 14 14
      events/on_action.py

+ 14 - 14
events/on_action.py

@@ -20,20 +20,9 @@ def process_event(self, connection, event):
         self.db.run("INSERT INTO \"users\" (name, network) VALUES ('" + event.source.nick + "', '" + self.network + "')")   # Create record.
     self.db.run("UPDATE \"users\" SET actions=actions+1 WHERE name='" + event.source.nick + "' AND network='" + self.network + "'") # Increment record.
     
-    # Respond to own name.
-    if connection.get_nickname().lower() in event.arguments[0].lower() and event.source.nick is not connection.get_nickname(): # Bot's name was mentioned,not by the bot itself.
-        
-        # Stop if channelfunction chat if off.
-        if not self.db.one("SELECT chat FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'"):
-            return
-        
-        # Stop if it's a slap.
-        if event.arguemnts[0].startswith() == "slaps ":
-            return
-        
-        Replyto.name(connection, event)
-    
-    
+    # Stop if channelfunction chat if off.
+    if not self.db.one("SELECT chat FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'"):
+        return
 
     # Slap guard.
     if event.arguments[0].lower().startswith("slaps ") and not event.target == connection.get_nickname():   # Channel action that stats with "slaps ".
@@ -44,12 +33,19 @@ def process_event(self, connection, event):
     
         # Only protect the worty.
         if not userstatus.atleast_voiced(self, event.arguments[0].split(" ")[1], self.homechannel) and not userstatus.atleast_oper(self, event.arguments[0].split(" ")[1], self.homechannel): # Insufficient rights.
+            if event.arguments[0].split(" ")[1].lower() == self.get_nickname(): # Bot slapped
+                Replyto.name(connection, event)
             return
         if userstatus.atleast_voiced(self, event.source.nick, self.homechannel):   # Slapper has atleast voice in home channel.
             if not self.channels[self.homechannel].is_owner(event.arguments[0].split(" ")[1]):  # Slappee is not owner.
+                if event.arguments[0].split(" ")[1].lower() == self.get_nickname(): # Bot slapped
+                    Replyto.name(connection, event)
                 return
             if self.channels[self.homechannel].is_owner(event.source.nick) and  self.channels[self.homechannel].is_owner(event.arguments[0].split(" ")[1]): # Slapper and slappee are owner.
+                if event.arguments[0].split(" ")[1].lower() == self.get_nickname(): # Bot slapped
+                    Replyto.name(connection, event)
                 return
+        
         # Respond.
         if " with a " in event.arguments[0]:
             if event.arguments[0].split(" with a ", maxsplit=1)[1]:
@@ -67,3 +63,7 @@ def process_event(self, connection, event):
                 connection.action(event.target, "bites " + red + event.source.nick + reset + " furiously.")
             else:
                 connection.action(event.target, "swiftly jumps in front of " + red + event.arguments[0].split(" ")[1] + reset + " to block the slap.")
+    
+    # Respond to own name.
+    elif connection.get_nickname().lower() in event.arguments[0].lower() and event.source.nick is not connection.get_nickname(): # Bot's name was mentioned, not by the bot itself.
+        Replyto.name(connection, event)