From 868568b3571429f934c14c285883fe4b677e930a Mon Sep 17 00:00:00 2001 From: Ollie Terrance Date: Thu, 26 May 2016 21:21:05 +0100 Subject: [PATCH] Add capabilities to user/endpoint events --- skpy/event.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/skpy/event.py b/skpy/event.py index 935edfc..7eb41e4 100644 --- a/skpy/event.py +++ b/skpy/event.py @@ -77,9 +77,11 @@ class SkypePresenceEvent(SkypeEvent): Whether the user is now connected. status (:class:`.Status`): Chosen availability status. + capabilities (str list): + Features currently available from this user, across all endpoints. """ - attrs = SkypeEvent.attrs + ("userId", "online", "status") + attrs = SkypeEvent.attrs + ("userId", "online", "status", "capabilities") @classmethod def rawToFields(cls, raw={}): @@ -88,7 +90,8 @@ def rawToFields(cls, raw={}): fields.update({ "userId": SkypeUtils.userToId(res.get("selfLink")), "online": res.get("availability") == "Online", - "status": getattr(SkypeUtils.Status, res.get("status")) + "status": getattr(SkypeUtils.Status, res.get("status")), + "capabilities": list(filter(None, res.get("capabilities", "").split(" | "))) }) return fields @@ -102,14 +105,23 @@ class SkypeEndpointEvent(SkypeEvent): Attributes: user (:class:`.SkypeUser`): User whose endpoint emitted an event. + name (str): + Name of the device connected with this endpoint. + capabilities (str list): + Features available on the device. """ - attrs = SkypeEvent.attrs + ("userId",) + attrs = SkypeEvent.attrs + ("userId", "name", "capabilities") @classmethod def rawToFields(cls, raw={}): fields = super(SkypeEndpointEvent, cls).rawToFields(raw) - fields["userId"] = SkypeUtils.userToId(raw.get("resource", {}).get("selfLink")) + res = raw.get("resource", {}) + fields.update({ + "userId": SkypeUtils.userToId(res.get("selfLink")), + "name": res.get("privateInfo", {}).get("epname"), + "capabilities": list(filter(None, res.get("publicInfo", {}).get("capabilities", "").split(" | "))) + }) return fields