Always display plugin errors

And fix !megakick once more.
This commit is contained in:
Alexei Sorokin 2017-06-11 14:42:44 +03:00
parent 720d17f6b9
commit fd078c43ad
1 changed files with 6 additions and 8 deletions

View File

@ -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, []))