diff --git a/docs/api/steam.client.builtins.rst b/docs/api/steam.client.builtins.rst index d79f8b5..fded53e 100644 --- a/docs/api/steam.client.builtins.rst +++ b/docs/api/steam.client.builtins.rst @@ -19,14 +19,6 @@ Web :undoc-members: :show-inheritance: -Misc ----- - -.. automodule:: steam.client.builtins.misc - :members: - :undoc-members: - :show-inheritance: - Unified Messages ---------------- diff --git a/steam/client/builtins/__init__.py b/steam/client/builtins/__init__.py index d497ff9..b2a79ea 100644 --- a/steam/client/builtins/__init__.py +++ b/steam/client/builtins/__init__.py @@ -1,7 +1,6 @@ """ 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.web import Web 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.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. The features are separated into submodules. diff --git a/steam/client/builtins/misc.py b/steam/client/builtins/misc.py deleted file mode 100644 index d0dea3d..0000000 --- a/steam/client/builtins/misc.py +++ /dev/null @@ -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) diff --git a/steam/client/builtins/user.py b/steam/client/builtins/user.py index 783184f..498f3ed 100644 --- a/steam/client/builtins/user.py +++ b/steam/client/builtins/user.py @@ -17,6 +17,7 @@ class User(object): persona_state = EPersonaState.Online #: current persona state user = None #: :class:`.SteamUser` instance once logged on + current_games_played = [] #: :class:`list` of app ids currently being played def __init__(self, *args, **kwargs): super(User, self).__init__(*args, **kwargs) @@ -105,3 +106,23 @@ class User(object): self.request_persona_state([steam_id]) 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) + } + )