From 9e03c263fed9555d5863114fd84deb195795d0e4 Mon Sep 17 00:00:00 2001 From: Davnit Date: Thu, 31 Oct 2019 11:58:40 -0400 Subject: [PATCH] More consistent return values from send-based CAPI functions send_chat() and bankickunban() now follow through and return the request ID of the sent message, or False if one was not sent. In the event of trying to whisper a user not in the channel, a malformed whisper request is no longer sent after the user isn't found. --- capi.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/capi.py b/capi.py index eb5bba7..8817523 100644 --- a/capi.py +++ b/capi.py @@ -209,22 +209,24 @@ def send_chat(self, message, mtype="channel", target=None): user = self.get_user(target) if user is None: self.parent.error(bncs.ERROR_NOTLOGGEDON) + return False else: payload["user_id"] = user.id - self.send_command(send_message_types.get(mtype), payload) + return self.send_command(send_message_types.get(mtype), payload) def bankickunban(self, target, action="ban"): user = self.get_user(target) if action.lower() != "unban" and user is None: self.parent.error(bncs.ERROR_NOTLOGGEDON) + return False else: action = bku_actions.get(action.lower()) if action is None: raise ValueError("Invalid ban/kick/unban action - must be %s" % ', '.join(bku_actions.keys())) payload = {"toon_name": target} if user is None else {"user_id": user.id} - self.send_command(action, payload) + return self.send_command(action, payload) def run(self): while self.connected():