Browse Source

builtins: merge Misc into User

pull/55/head
Rossen Georgiev 9 years ago
parent
commit
e722290aad
  1. 8
      docs/api/steam.client.builtins.rst
  2. 3
      steam/client/builtins/__init__.py
  3. 29
      steam/client/builtins/misc.py
  4. 21
      steam/client/builtins/user.py

8
docs/api/steam.client.builtins.rst

@ -19,14 +19,6 @@ Web
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
Misc
----
.. automodule:: steam.client.builtins.misc
:members:
:undoc-members:
:show-inheritance:
Unified Messages Unified Messages
---------------- ----------------

3
steam/client/builtins/__init__.py

@ -1,7 +1,6 @@
""" """
All high level features of :class:`steam.client.SteamClient` are implemented here in separate submodules. All high level features of :class:`steam.client.SteamClient` are implemented here in separate submodules.
""" """
from steam.client.builtins.misc import Misc
from steam.client.builtins.user import User from steam.client.builtins.user import User
from steam.client.builtins.web import Web from steam.client.builtins.web import Web
from steam.client.builtins.unified_messages import UnifiedMessages from steam.client.builtins.unified_messages import UnifiedMessages
@ -9,7 +8,7 @@ from steam.client.builtins.leaderboards import Leaderboards
from steam.client.builtins.gameservers import GameServers from steam.client.builtins.gameservers import GameServers
from steam.client.builtins.friends import Friends from steam.client.builtins.friends import Friends
class BuiltinBase(Misc, User, Web, UnifiedMessages, Leaderboards, GameServers, Friends): class BuiltinBase(User, Web, UnifiedMessages, Leaderboards, GameServers, Friends):
""" """
This object is used as base to implement all high level functionality. This object is used as base to implement all high level functionality.
The features are separated into submodules. The features are separated into submodules.

29
steam/client/builtins/misc.py

@ -1,29 +0,0 @@
"""
Various features that don't have a category
"""
from steam.core.msg import MsgProto
from steam.enums.emsg import EMsg
class Misc(object):
def __init__(self, *args, **kwargs):
super(Misc, self).__init__(*args, **kwargs)
def games_played(self, app_ids):
"""
Set the application being played by the user
:param app_ids: a list of application ids
:type app_ids: :class:`list`
"""
if not isinstance(app_ids, list):
raise ValueError("Expected app_ids to be of type list")
app_ids = map(int, app_ids)
message = MsgProto(EMsg.ClientGamesPlayed)
GamePlayed = message.body.GamePlayed
message.body.games_played.extend(map(lambda x: GamePlayed(game_id=x), app_ids))
self.send(message)

21
steam/client/builtins/user.py

@ -17,6 +17,7 @@ class User(object):
persona_state = EPersonaState.Online #: current persona state persona_state = EPersonaState.Online #: current persona state
user = None #: :class:`.SteamUser` instance once logged on user = None #: :class:`.SteamUser` instance once logged on
current_games_played = [] #: :class:`list` of app ids currently being played
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(User, self).__init__(*args, **kwargs) super(User, self).__init__(*args, **kwargs)
@ -105,3 +106,23 @@ class User(object):
self.request_persona_state([steam_id]) self.request_persona_state([steam_id])
return suser return suser
def games_played(self, app_ids):
"""
Set the apps being played by the user
:param app_ids: a list of application ids
:type app_ids: :class:`list`
These app ids will be recorded in :attr:`current_games_played`.
"""
if not isinstance(app_ids, list):
raise ValueError("Expected app_ids to be of type list")
self.current_games_played = app_ids = map(int, app_ids)
self.send(MsgProto(EMsg.ClientGamesPlayed),
{
'games_played': map(lambda app_id: {'game_id': app_id}, app_ids)
}
)

Loading…
Cancel
Save