From 17f5316f17fbd43007bcfc501477b4b1084835d9 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Sat, 29 Feb 2020 11:57:01 +0100 Subject: [PATCH] hugfix --- distbot/plugins/fun.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/distbot/plugins/fun.py b/distbot/plugins/fun.py index bf6fe87..9d8a795 100644 --- a/distbot/plugins/fun.py +++ b/distbot/plugins/fun.py @@ -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] -- 2.39.2