diff --git a/steam/client/__init__.py b/steam/client/__init__.py index ae8cc87..b24cb6f 100644 --- a/steam/client/__init__.py +++ b/steam/client/__init__.py @@ -4,7 +4,7 @@ import gevent from Crypto.Hash import SHA from eventemitter import EventEmitter from steam.enums.emsg import EMsg -from steam.enums import EResult, EOSType +from steam.enums import EResult, EOSType, EPersonaState from steam.core.msg import MsgProto from steam.core.cm import CMClient from steam import SteamID @@ -107,6 +107,7 @@ class SteamClient(EventEmitter, FeatureBase): if result == EResult.OK: self.logged_on = True + self.set_persona(EPersonaState.Online) self.emit("logged_on") return diff --git a/steam/client/features/user.py b/steam/client/features/user.py index 7985aa1..f7cc25c 100644 --- a/steam/client/features/user.py +++ b/steam/client/features/user.py @@ -1,4 +1,27 @@ +from steam.enums import EPersonaState +from steam.enums.emsg import EMsg +from steam.core.msg import MsgProto class User(object): def __init__(self): super(User, self).__init__() + + def set_persona(self, state, name=None): + """ + Set persona state and name + + :param state: persona state flag + :type state: :class:`steam.enums.common.EPersonaState` + :param name: profile name + :type name: :class:`str` + """ + if not isinstance(state, EPersonaState): + raise ValueError("Expected state to be instance of EPersonaState") + + message = MsgProto(EMsg.ClientChangeStatus) + + message.body.persona_state = state + if name: + message.body.player_name = name + + self.send(message)