浏览代码

slap guard

tBKwtWS 7 年之前
父节点
当前提交
93fd727074
共有 3 个文件被更改,包括 37 次插入13 次删除
  1. 34 0
      events/on_action.py
  2. 1 1
      events/on_pubmsg.py
  3. 2 12
      rotbot.py

+ 34 - 0
events/on_action.py

@@ -0,0 +1,34 @@
+from common import userstatus
+
+bold = "\x02"
+italic = "\x1D"
+underline = "\x1F"
+reverse = "\x16"    # swap background and foreground colors ("reverse video")
+reset = "\x0F"
+blue = "\x0302"
+green = "\x0303"
+red = "\x0304"
+grey = "\x0314"
+
+def process_event(self, connection, event):
+
+    # Slap guard.
+    if not self.db.one("SELECT chat FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'"):
+        return  # Stop if chat channel function is off.
+    if event.arguments[0].lower().startswith("slaps ") and not event.target == connection.get_nickname():   # Channel action that stats with "slaps ".
+        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.
+            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.
+                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.
+                return
+
+        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.")
+                return
+
+            connection.action(event.target, "swiftly jumps in front of " + red + event.arguments[0].split(" ")[1] + reset + " to block the slap.")
+        elif len(event.arguments[0].split(" ")) > 1:
+            connection.action(event.target, "swiftly jumps in front of " + red + event.arguments[0].split(" ")[1] + reset + " to block the slap.")

+ 1 - 1
events/on_pubmsg.py

@@ -72,4 +72,4 @@ def process_event(self, connection, event):
         # Update lastlame.
         self.db.run("UPDATE channels SET last_lame='" + str(datetime.datetime.now()) + "' WHERE name='" + event.target + "' AND network='" + self.network + "'")
         
-        connection.privmsg(event.target, event.arguments[0] + ".")
+        connection.privmsg(event.target, event.arguments[0] + event.arguments[0][:1])

+ 2 - 12
rotbot.py

@@ -5,20 +5,10 @@ import irc.bot#, irc.strings
 from irc.client import ip_numstr_to_quad#, ip_quad_to_numstr
 from postgres import Postgres
 import commands.public, commands.admin, commands.games, commands.statistics
-import events.on_welcome, events.on_join, events.on_kick, events.on_mode, events.on_pubmsg, events.on_whoreply, events.on_nick
+import events.on_welcome, events.on_join, events.on_kick, events.on_mode, events.on_pubmsg, events.on_action, events.on_whoreply, events.on_nick
 from common import log
 from common.networkservices import NickServ
 
-bold = "\x02"
-italic = "\x1D"
-underline = "\x1F"
-reverse = "\x16"    # swap background and foreground colors ("reverse video")
-reset = "\x0F"
-blue = "\x0302"
-green = "\x0303"
-red = "\x0304"
-grey = "\x0314"
-
 class PyRot(irc.bot.SingleServerIRCBot):
     def __init__(self, network, db, homechannel, nickname, username, password, host, port=6667, usessl=False, cmdchar="!", helpchar="@"):
         self.network = network
@@ -113,7 +103,7 @@ class PyRot(irc.bot.SingleServerIRCBot):
             connection.join(event.arguments[0].split(' ')[3], event.arguments[0].split(' ')[5][:-1])
     
     def on_action(self, connection, event):
-        log.info(event)
+        events.on_action.process_event(self, connection, event)
     
     
     def on_whoreply(self, connection, event):