Split ._parseMessage to reduce indentation
This commit is contained in:
@@ -2751,27 +2751,8 @@ class Client(object):
|
||||
else:
|
||||
self.onUnknownMesssageType(msg=m)
|
||||
|
||||
def _parseMessage(self, content):
|
||||
"""Get message and author name from content.
|
||||
|
||||
May contain multiple messages in the content.
|
||||
"""
|
||||
self._seq = content.get("seq", "0")
|
||||
|
||||
if "lb_info" in content:
|
||||
self._sticky = content["lb_info"]["sticky"]
|
||||
self._pool = content["lb_info"]["pool"]
|
||||
|
||||
if "batches" in content:
|
||||
for batch in content["batches"]:
|
||||
self._parseMessage(batch)
|
||||
|
||||
if "ms" not in content:
|
||||
return
|
||||
|
||||
for m in content["ms"]:
|
||||
def _parse_payload(self, m):
|
||||
mtype = m.get("type")
|
||||
try:
|
||||
# Things that directly change chat
|
||||
if mtype == "delta":
|
||||
self._parseDelta(m)
|
||||
@@ -2842,9 +2823,7 @@ class Client(object):
|
||||
if id_ in self._buddylist:
|
||||
old_in_game = self._buddylist[id_].in_game
|
||||
|
||||
statuses[id_] = ActiveStatus._from_buddylist_overlay(
|
||||
data, old_in_game
|
||||
)
|
||||
statuses[id_] = ActiveStatus._from_buddylist_overlay(data, old_in_game)
|
||||
self._buddylist[id_] = statuses[id_]
|
||||
|
||||
self.onBuddylistOverlay(statuses=statuses, msg=m)
|
||||
@@ -2853,6 +2832,27 @@ class Client(object):
|
||||
else:
|
||||
self.onUnknownMesssageType(msg=m)
|
||||
|
||||
def _parseMessage(self, content):
|
||||
"""Get message and author name from content.
|
||||
|
||||
May contain multiple messages in the content.
|
||||
"""
|
||||
self._seq = content.get("seq", "0")
|
||||
|
||||
if "lb_info" in content:
|
||||
self._sticky = content["lb_info"]["sticky"]
|
||||
self._pool = content["lb_info"]["pool"]
|
||||
|
||||
if "batches" in content:
|
||||
for batch in content["batches"]:
|
||||
self._parseMessage(batch)
|
||||
|
||||
if "ms" not in content:
|
||||
return
|
||||
|
||||
for m in content["ms"]:
|
||||
try:
|
||||
self._parse_payload(m)
|
||||
except Exception as e:
|
||||
self.onMessageError(exception=e, msg=m)
|
||||
|
||||
|
Reference in New Issue
Block a user