Kaynağa Gözat

act&say help, nickreply refactor

tBKwtWS 7 yıl önce
ebeveyn
işleme
d54daf0816

+ 1 - 1
.eric6project/pyRot.e4q

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
 <!-- eric6 user project file for project pyRot -->
-<!-- Saved: 2018-01-27, 00:37:00 -->
+<!-- Saved: 2018-01-27, 19:55:21 -->
 <!-- Copyright (C) 2018 tBKwtWS,  -->
 <UserProject version="4.0"/>

+ 3 - 3
.eric6project/pyRot.e6t

@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE Tasks SYSTEM "Tasks-6.0.dtd">
 <!-- eric6 tasks file for project pyRot -->
-<!-- Saved: 2018-01-27, 10:45:12 -->
+<!-- Saved: 2018-01-27, 22:56:10 -->
 <Tasks version="6.0">
   <ProjectScanFilter></ProjectScanFilter>
-  <Task priority="1" completed="False" type="2" uid="{18a4cff9-77ab-44ac-9bb4-74d878d83cbd}">
+  <Task priority="1" completed="False" type="2" uid="{241fd9ce-7896-465b-ab1c-2dc0a9fa89ea}">
     <Summary>WARNING: &quot; + str(message))</Summary>
     <Description></Description>
-    <Created>2018-01-27, 10:45:09</Created>
+    <Created>2018-01-27, 22:56:07</Created>
     <Resource>
       <Filename>common/log.py</Filename>
       <Linenumber>8</Linenumber>

+ 1 - 1
commands/admin.py

@@ -162,7 +162,7 @@ def do_command(self, connection, event):
                 message = "Let " + connection.get_nickname() + "send a message to a channel."
                 arguments = "name message"
             connection.privmsg(replyto, message)
-            connection.privmsg(replyto, grey + "Usage: " + blue + "!" + command.split(maxsplit=1)[0] + " " + reset + italic + arguments)
+            connection.privmsg(replyto, grey + "Usage: " + blue + "!" + command.split(maxsplit=1)[0] + reset + italic + " target " + arguments)
         elif cmdtype == "cmd":
             
             # Parse user input.

+ 0 - 2
commands/public.py

@@ -28,8 +28,6 @@ def do_command(self, connection, event):
                 connection.privmsg(replyto, event)
             else:   # Channel message.
                 connection.privmsg(replyto, str(self.channels[event.target]))
-                print(connection.userhost(event.source.nick))   # Empty reply on GamerGalaxy, check what happens on GTAnet.
-                print(connection.who(event.source.nick))
             
     elif command == "cmd" or command == "commands":
         if cmdtype == "help":    #Display help text.

+ 53 - 0
events/common.py

@@ -1,3 +1,4 @@
+import random
 from common import userstatus
 class Protectees():
     def update(self, nick, user, host):
@@ -10,6 +11,58 @@ class Protectees():
             if userstatus.atleast_halfop(self, user, self.homechannel) or nick == self.connection.get_nickname():   # Update. Is atleast halfop or bot itself.
                 self.protectees[nick] = {'ident': nick + "!" + user + "@" + host}
 
+class Replyto():
+    def name(connection, event):
+        messages = [
+            "Hello " + event.source.nick + ".", 
+            "How are you today " + event.source.nick +  "?", 
+            "Piss off " + event.source.nick + "!", 
+            event.source.nick + ", what are you botherring me for?", 
+            "Go bother someone else...", 
+            "Is life treating you fair?", 
+            "What's up?", 
+            "Why are you talking to me?", 
+            "I'm not talking to you!", 
+            "What have you been up to?", 
+            "How is life?", 
+            "What do you wan't from me?", 
+            event.source.nick + ", why are you bothering me?", 
+            event.source.nick + ", when will you stop talking about me?", 
+            event.source.nick + " I hate you!", 
+            "Get bent!", 
+            "Go and cut yourself.", 
+            "Do you think i care about you?", 
+            "Stop nickalerting me " + event.source.nick + ", you wanker!", 
+        ]
+        actions = [
+            "hides!",
+            "dies.", 
+            "runs away.", 
+            "is ignoring that.", 
+            "is not feeling like caring.", 
+            "is away", 
+            "will be ignoring that.", 
+            "is faggaliciouz!! <333", 
+            "likes you! <3", 
+            "looks the other way...", 
+            "does a little dance with " + event.source.nick + ".", 
+            "makes a little love.", 
+            "get's down tonight.", 
+            "thinks SAM Broadcaster sucks raw cocks in hell!", 
+            "is secretly in love with " + event.source.nick + ".", 
+            "tosses " + event.source.nick + "'s salad.", 
+            "tortures " + event.source.nick + " horribly!", 
+            "is smelling like tuna when looking at " + event.source.nick + ".", 
+            "sniffing armpits.. Eew! Smells like " + event.source.nick + ".", 
+            "rapes " + event.source.nick + ".", 
+        ]
+        
+        # Reply with a random message or action.
+        if random.randint(0, 1) == 0:
+            connection.privmsg(event.target, random.choice(messages))
+        else:
+            connection.action(event.target, random.choice(actions))
+            
 class Aggressiveness():
     def retalliation_reason(self, connection, protectee, behaviour):
         if protectee == connection.get_nickname():  # Bot itself.

+ 3 - 1
events/on_action.py

@@ -1,4 +1,5 @@
 from common import userstatus
+from events.common import Replyto
 
 bold = "\x02"
 italic = "\x1D"
@@ -11,6 +12,7 @@ red = "\x0304"
 grey = "\x0314"
 
 def process_event(self, connection, event):
+    Replyto.name(connection, event)
 
     # Slap guard.
     if not self.db.one("SELECT chat FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'"):
@@ -26,7 +28,7 @@ def process_event(self, connection, event):
 
         if " with a " in event.arguments[0]:
             if event.arguments[0].split(" with a ", maxsplit=1)[1]:
-                connection.action(event.target, "swiftly jumps in front of " + red + event.arguments[0].split(" ")[1] + reset + " to block the " + event.arguments[0].split(" with a ", maxsplit=1)[1] + " with his face.")
+                connection.action(event.target, "swiftly jumps in front of " + red + event.arguments[0].split(" ")[1] + reset + " to block the " + event.arguments[0].split(" with a ", maxsplit=1)[1])
                 return
 
             connection.action(event.target, "swiftly jumps in front of " + red + event.arguments[0].split(" ")[1] + reset + " to block the slap.")

+ 0 - 1
events/on_mode.py

@@ -15,7 +15,6 @@ red = "\x0304"
 grey = "\x0314"
 
 def process_event(self, connection, event):
-    print(event)
     
     # Update protectees.
     if event.target == self.homechannel:    # Home channel

+ 3 - 50
events/on_pubmsg.py

@@ -1,4 +1,5 @@
-import random, datetime
+import datetime
+from events.common import Replyto
 
 def process_event(self, connection, event):
     if connection.get_nickname().lower() in event.arguments[0].lower() and event.source.nick is not connection.get_nickname(): # Bot's name was mentioned
@@ -7,55 +8,7 @@ def process_event(self, connection, event):
         if not self.db.one("SELECT chat FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'"):
             return  # Stop if channelfunction chat if off.
         
-        messages = [
-            "Hello " + event.source.nick + ".", 
-            "How are you today " + event.source.nick +  "?", 
-            "Piss off " + event.source.nick + "!", 
-            event.source.nick + ", what are you botherring me for?", 
-            "Go bother someone else...", 
-            "Is life treating you fair?", 
-            "What's up?", 
-            "Why are you talking to me?", 
-            "I'm not talking to you!", 
-            "What have you been up to?", 
-            "How is life?", 
-            "What do you wan't from me?", 
-            event.source.nick + ", why are you bothering me?", 
-            event.source.nick + ", when will you stop talking about me?", 
-            event.source.nick + " I hate you!", 
-            "Get bent!", 
-            "Go and cut yourself.", 
-            "Do you think i care about you?", 
-            "Stop nickalerting me " + event.source.nick + ", you wanker!", 
-        ]
-        actions = [
-            "hides!",
-            "dies.", 
-            "runs away.", 
-            "is ignoring that.", 
-            "is not feeling like caring.", 
-            "is away", 
-            "will be ignoring that.", 
-            "is faggaliciouz!! <333", 
-            "likes you! <3", 
-            "looks the other way...", 
-            "does a little dance with " + event.source.nick + ".", 
-            "makes a little love.", 
-            "get's down tonight.", 
-            "thinks SAM Broadcaster sucks raw cocks in hell!", 
-            "is secretly in love with " + event.source.nick + ".", 
-            "tosses " + event.source.nick + "'s salad.", 
-            "tortures " + event.source.nick + " horribly!", 
-            "is smelling like tuna when looking at " + event.source.nick + ".", 
-            "sniffing armpits.. Eew! Smells like " + event.source.nick + ".", 
-            "rapes " + event.source.nick + ".", 
-        ]
-        
-        # Reply with a random message or action.
-        if random.randint(0, 1) == 0:
-            connection.privmsg(event.target, random.choice(messages))
-        else:
-            connection.action(event.target, random.choice(actions))
+        Replyto.name(connection, event)
     
     # Character lame.
     elif event.arguments[0] == len(event.arguments[0]) * event.arguments[0][0]:   # Trigger exclusively same character.

+ 2 - 1
pyRot.e4p

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE Project SYSTEM "Project-5.1.dtd">
 <!-- eric project file for project pyRot -->
-<!-- Saved: 2018-01-27, 00:37:00 -->
+<!-- Saved: 2018-01-27, 19:55:21 -->
 <!-- Copyright (C) 2018 tBKwtWS,  -->
 <Project version="5.1">
   <Language>en_US</Language>
@@ -24,6 +24,7 @@
     <Source>common/networkservices.py</Source>
     <Source>common/userstatus.py</Source>
     <Source>events/common.py</Source>
+    <Source>events/on_action.py</Source>
     <Source>events/on_join.py</Source>
     <Source>events/on_kick.py</Source>
     <Source>events/on_mode.py</Source>