From fd078c43adb8a14544c80f5653e066816dc3e28c Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Sun, 11 Jun 2017 14:42:44 +0300 Subject: [PATCH] Always display plugin errors And fix !megakick once more. --- hptoad.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hptoad.py b/hptoad.py index 5e51928..a839e79 100755 --- a/hptoad.py +++ b/hptoad.py @@ -147,6 +147,7 @@ class Hptoad: @asyncio.coroutine def handle_command(self, command, body, nick, from_id, is_admin): if command == "megakick": # Megakick. + reply = None victim = body if victim: is_bot_admin = self.is_muc_admin(self.muc, self.bot_nick) @@ -163,8 +164,9 @@ class Hptoad: else: reply = "%s: WAT" % nick - self.client.send_message(mto=self.muc, mbody=reply, - mtype="groupchat") + if reply: + self.client.send_message(mto=self.muc, mbody=reply, + mtype="groupchat") else: # Any plugin command. futures = [] @@ -299,10 +301,10 @@ class Hptoad: def on_plugin_got_result(self, future, nick="", from_id="", is_admin=False): result = future.result() - if not result or not result["handled"]: + if not result: return - if result["reply"]: + if result["handled"] and result["reply"]: self.client.send_message(mto=self.muc, mbody=result["reply"], mtype="groupchat") @@ -312,10 +314,6 @@ class Hptoad: self.client.send_message(mto=from_id, mbody=result["error"], mtype="chat") - if nick: - self.client.send_message(mto=self.muc, mbody="%s: WAT" % nick, - mtype="groupchat") - def import_plugins(self): plugins = {} _, _, filenames = next(os.walk("./plugins"), (None, None, []))