]> git.aero2k.de Git - urlbot-v3.git/commitdiff
hugfix
authorThorsten <mail@aero2k.de>
Sat, 29 Feb 2020 10:57:01 +0000 (11:57 +0100)
committerThorsten <mail@aero2k.de>
Sat, 29 Feb 2020 10:57:01 +0000 (11:57 +0100)
distbot/plugins/fun.py

index bf6fe87d4948d4d260be37c804f81a3516fc1dc3..9d8a7951a00e07ff8cb834c3fd128743bafef6ae 100644 (file)
@@ -54,29 +54,18 @@ class Unicode(Worker):
 
 
 class Slap(Worker):
-    binding_keys = ["nick.slap.#"]
-    description = "slap people"
+    binding_keys = ["nick.slap.#", "nick.hug.#"]
+    description = "slap/hug people"
 
     def parse_body(self, msg):
         sender = get_nick_from_message(msg)
-        if len(self.used_channel) > 2:
-            slapped = " ".join(self.used_channel[2:])
+        w = get_words(msg)
+        verb = w[0] + 's'
+        if len(w) > 1:
+            subject = " ".join(w[1:])
         else:
-            slapped = sender
-        return Action(msg='/me slaps {}'.format(slapped))
-
-
-class Hug(Worker):
-    binding_keys = ["nick.hug.#"]
-    description = "hugs people"
-
-    def parse_body(self, msg):
-        sender = get_nick_from_message(msg)
-        if len(self.used_channel) > 2:
-            slapped = " ".join(self.used_channel[2:])
-        else:
-            slapped = sender
-        return Action(msg='/me hugs {}'.format(slapped))
+            subject = sender
+        return Action(msg=f'/me {verb} {subject}')
 
 
 class Consumables(Worker):
@@ -184,4 +173,4 @@ class Doctor(Worker):
         return Action(msg="ELIMINATE! ELIMINATE!")
 
 
-ALL = [Klammer, Terminate, Unicode, Hug, Slap, Consumables, MentalDeficits, Selfreaction, Doctor]
+ALL = [Klammer, Terminate, Unicode, Slap, Consumables, MentalDeficits, Selfreaction, Doctor]