From 6b992e13b649154da86910f4bc343e7064b37fcf Mon Sep 17 00:00:00 2001 From: Thorsten Date: Sat, 29 Feb 2020 10:35:21 +0100 Subject: [PATCH] fix aftermath of ff58ead1bc5037d3114457d1d13e8d09223bada6 --- distbot/bot/bot.py | 13 ++++++++++--- distbot/plugins/debug.py | 13 ++++++++++++- distbot/plugins/fun.py | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/distbot/bot/bot.py b/distbot/bot/bot.py index 7c7af7f..72c9511 100644 --- a/distbot/bot/bot.py +++ b/distbot/bot/bot.py @@ -125,13 +125,20 @@ class Bot(sleekxmpp.ClientXMPP): # simplify the key significantly key = shlex.split(re.sub(r'[^a-z0-9 "\']', '', msg["body"].lower())) + if not key: + # simple dots, smilies, emoji shit, pass through + key = shlex.split(msg["body"].lower()) # cut the nick from the message offset = 0 if self.nick.lower() in key[0].lower(): - key.pop(0) - key.insert(0, "nick") - offset = len(self.nick) + 1 + if message[0] == '>': + key.pop(0) + key.insert(0, "quoted_nick") + else: + key.pop(0) + key.insert(0, "nick") + offset = message.find(self.nick) + len(self.nick) + 1 if msg["type"] == "groupchat": recipient = msg["mucroom"] diff --git a/distbot/plugins/debug.py b/distbot/plugins/debug.py index 3158456..c4bb3b3 100644 --- a/distbot/plugins/debug.py +++ b/distbot/plugins/debug.py @@ -19,4 +19,15 @@ class Echo(Worker): return Action(msg=message) -ALL = [Echo] +class Parrot(Worker): + binding_keys = Worker.CATCH_ALL + ["nick.repeat"] + description = "a most handsome parrot bot" + usage = "bot: repeat" + uses_history = True + + def parse_body(self, msg): + if self.history and 'repeat' in self.used_channel: + return Action(msg=self.history[-1]["body"]) + + +ALL = [Echo, Parrot] diff --git a/distbot/plugins/fun.py b/distbot/plugins/fun.py index 75b97cc..bf6fe87 100644 --- a/distbot/plugins/fun.py +++ b/distbot/plugins/fun.py @@ -157,7 +157,7 @@ class MentalDeficits(Worker): class Selfreaction(Worker): - binding_keys = ["/me.#.{}.#".format(conf_get("bot_nickname"))] + binding_keys = ["me.#.{}.#".format(conf_get("bot_nickname"))] description = "reacts to being talked about" me_replys = [ -- 2.39.2