From 39e2267022ef3292ecded938088b61f23e359598 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Thu, 17 Nov 2016 16:33:37 +0200 Subject: [PATCH] SteamUser: get_ps will request persona state when missing related to #52 --- steam/client/builtins/user.py | 6 ++++-- steam/client/user.py | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/steam/client/builtins/user.py b/steam/client/builtins/user.py index 9a7c6dc..bfb6e5e 100644 --- a/steam/client/builtins/user.py +++ b/steam/client/builtins/user.py @@ -74,11 +74,13 @@ class User(object): proto_fill_from_dict(message.body, kwargs) self.send(message) - def request_persona_state(self, steam_ids, state_flags=3418): + def request_persona_state(self, steam_ids, state_flags=863): """Request persona state data :param steam_ids: list of steam ids - :type steam_ids: :class:`list` + :type steam_ids: :class:`list` + :param state_flags: client state flags + :type state_flags: :class:`.EClientPersonaStateFlag` """ m = MsgProto(EMsg.ClientRequestFriendData) m.body.persona_state_requested = state_flags diff --git a/steam/client/user.py b/steam/client/user.py index 9e9138c..67cf293 100644 --- a/steam/client/user.py +++ b/steam/client/user.py @@ -26,7 +26,11 @@ class SteamUser(object): ) def get_ps(self, field_name, wait_pstate=True): - if not wait_pstate or self._pstate_ready.wait(timeout=30): + if not wait_pstate or self._pstate_ready.wait(timeout=5): + if self._pstate is None and wait_pstate: + self._steam.request_persona_state([self.steam_id]) + self._pstate_ready.wait(timeout=5) + if self._pstate and self._pstate.HasField(field_name): return getattr(self._pstate, field_name) return None