Fix chat timestamp parsing
This commit is contained in:
@@ -2773,26 +2773,19 @@ class Client(object):
|
|||||||
from_id = m["from"]
|
from_id = m["from"]
|
||||||
self.onFriendRequest(from_id=from_id, msg=m)
|
self.onFriendRequest(from_id=from_id, msg=m)
|
||||||
|
|
||||||
# Chat timestamp
|
# Chat timestamp / Buddylist overlay
|
||||||
elif topic == "chatproxy-presence":
|
elif topic == "/orca_presence":
|
||||||
statuses = dict()
|
if m["list_type"] == "full":
|
||||||
for id_, data in m.get("buddyList", {}).items():
|
self._buddylist = {} # Refresh internal list
|
||||||
statuses[id_] = ActiveStatus._from_chatproxy_presence(id_, data)
|
|
||||||
self._buddylist[id_] = statuses[id_]
|
|
||||||
|
|
||||||
|
statuses = dict()
|
||||||
|
for data in m["list"]:
|
||||||
|
user_id = str(data["u"])
|
||||||
|
statuses[user_id] = ActiveStatus._from_orca_presence(data)
|
||||||
|
self._buddylist[user_id] = statuses[user_id]
|
||||||
|
|
||||||
|
# TODO: Which one should we call?
|
||||||
self.onChatTimestamp(buddylist=statuses, msg=m)
|
self.onChatTimestamp(buddylist=statuses, msg=m)
|
||||||
|
|
||||||
# Buddylist overlay
|
|
||||||
elif topic == "buddylist_overlay":
|
|
||||||
statuses = dict()
|
|
||||||
for id_, data in m.get("overlay", {}).items():
|
|
||||||
old_in_game = None
|
|
||||||
if id_ in self._buddylist:
|
|
||||||
old_in_game = self._buddylist[id_].in_game
|
|
||||||
|
|
||||||
statuses[id_] = ActiveStatus._from_buddylist_overlay(data, old_in_game)
|
|
||||||
self._buddylist[id_] = statuses[id_]
|
|
||||||
|
|
||||||
self.onBuddylistOverlay(statuses=statuses, msg=m)
|
self.onBuddylistOverlay(statuses=statuses, msg=m)
|
||||||
|
|
||||||
# Unknown message type
|
# Unknown message type
|
||||||
@@ -3807,7 +3800,6 @@ class Client(object):
|
|||||||
statuses (dict): Dictionary with user IDs as keys and :class:`ActiveStatus` as values
|
statuses (dict): Dictionary with user IDs as keys and :class:`ActiveStatus` as values
|
||||||
msg: A full set of the data received
|
msg: A full set of the data received
|
||||||
"""
|
"""
|
||||||
log.debug("Buddylist overlay received: {}".format(statuses))
|
|
||||||
|
|
||||||
def onUnknownMesssageType(self, msg=None):
|
def onUnknownMesssageType(self, msg=None):
|
||||||
"""Called when the client is listening, and some unknown data was received.
|
"""Called when the client is listening, and some unknown data was received.
|
||||||
|
@@ -192,17 +192,6 @@ class ActiveStatus(object):
|
|||||||
in_game = attr.ib(None)
|
in_game = attr.ib(None)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _from_chatproxy_presence(cls, id_, data):
|
def _from_orca_presence(cls, data):
|
||||||
return cls(
|
# TODO: Handle `c` and `vc` keys (Probably some binary data)
|
||||||
active=data["p"] in [2, 3] if "p" in data else None,
|
return cls(active=data["p"] in [2, 3], last_active=data.get("l"), in_game=None)
|
||||||
last_active=data.get("lat"),
|
|
||||||
in_game=int(id_) in data.get("gamers", {}),
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _from_buddylist_overlay(cls, data, in_game=None):
|
|
||||||
return cls(
|
|
||||||
active=data["a"] in [2, 3] if "a" in data else None,
|
|
||||||
last_active=data.get("la"),
|
|
||||||
in_game=None,
|
|
||||||
)
|
|
||||||
|
Reference in New Issue
Block a user