From cdc906c0a4113f07105416ebfa12eb33b22235e0 Mon Sep 17 00:00:00 2001 From: Marenthyu Date: Thu, 16 Nov 2017 14:19:14 +0100 Subject: [PATCH] Make rescue platform default to None instead of 'unknown', which would be invalid --- sopel-modules/rat-board.py | 8 ++++---- sopel-modules/rat-socket.py | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sopel-modules/rat-board.py b/sopel-modules/rat-board.py index c66c858..2490e95 100644 --- a/sopel-modules/rat-board.py +++ b/sopel-modules/rat-board.py @@ -325,7 +325,7 @@ class Rescue(TrackedBase): rats = SetProperty(default=lambda: set()) unidentifiedRats = SetProperty(default=lambda: set()) quotes = ListProperty(default=lambda: []) - platform = TrackedProperty(default='unknown') + platform = TrackedProperty(default=None) open = TypeCoercedProperty(default=True, coerce=bool) epic = TypeCoercedProperty(default=False, coerce=bool) codeRed = TypeCoercedProperty(default=False, coerce=bool) @@ -653,7 +653,7 @@ def append_quotes(bot, search, lines, autocorrect=True, create=True, detect_plat rv.detected_system = systems.pop() rv.added_lines.append("[Autodetected system: {}]".format(rv.detected_system)) rv.rescue.system = rv.detected_system - if detect_platform and rv.rescue.platform == 'unknown': + if detect_platform and rv.rescue.platform == None: platforms = set() for line in rv.added_lines: if re.search( @@ -984,7 +984,7 @@ def format_rescue(bot, rescue, attr='client_name', showassigned=False, showids=T cl = (('Operation ' + rescue.title) if rescue.title else (getattr(rescue, attr))) platform = rescue.platform assignedratsstring = '' - if platform == 'unknown': + if platform == None: platform = '' if platform == 'xb': platform = color(' XB', colors.GREEN) @@ -1187,7 +1187,7 @@ def cmd_assign(bot, trigger, rescue, *rats): ratlist = [] ratids = [] for rat in rats: - if rescue.platform == 'unknown': + if rescue.platform == None: i = getRatId(bot, rat) else: i = getRatId(bot, rat, platform=rescue.platform) diff --git a/sopel-modules/rat-socket.py b/sopel-modules/rat-socket.py index 39fab7b..769aca9 100644 --- a/sopel-modules/rat-socket.py +++ b/sopel-modules/rat-socket.py @@ -204,9 +204,12 @@ def handleWSMessage(payload, senderinstance): data = response['data'] if 'action' in response.keys(): action = response['action'][0] - else: + elif 'meta' in response.keys(): action = response['meta']['event'] - except KeyError: + else: + data = data['attributes'] + action = data['event'] + except: print("[Websocket] Message: " + str(response)) print("[Websocket] Couldn't get data or action - Ignoring Websocket Event.") return