3 changed files with 33 additions and 29 deletions
@ -1,32 +1,37 @@ |
|||||
from steam.enums import EPersonaState |
from steam.enums import EPersonaState |
||||
from steam.enums.emsg import EMsg |
from steam.enums.emsg import EMsg |
||||
from steam.core.msg import MsgProto |
from steam.core.msg import MsgProto |
||||
|
from steam.util import proto_fill_from_dict |
||||
|
|
||||
class User(object): |
class User(object): |
||||
|
persona_state = EPersonaState.Online #: current persona state |
||||
|
|
||||
def __init__(self, *args, **kwargs): |
def __init__(self, *args, **kwargs): |
||||
super(User, self).__init__(*args, **kwargs) |
super(User, self).__init__(*args, **kwargs) |
||||
|
|
||||
def set_persona(self, state=None, name=None): |
self.on(self.EVENT_LOGGED_ON, self.__handle_set_persona) |
||||
""" |
|
||||
Set persona state and/or name |
|
||||
|
|
||||
:param state: persona state flag |
def __handle_set_persona(self): |
||||
:type state: :class:`steam.enums.common.EPersonaState` |
self.set_persona(persona_state=self.persona_state) |
||||
:param name: profile name |
|
||||
:type name: :class:`str` |
|
||||
""" |
|
||||
if state is None and name is None: |
|
||||
return |
|
||||
|
|
||||
message = MsgProto(EMsg.ClientChangeStatus) |
def change_status(self, **kwargs): |
||||
|
""" |
||||
|
Set name, persona state, flags |
||||
|
|
||||
if state: |
.. note:: |
||||
if not isinstance(state, EPersonaState): |
Changing persona state will also change :attr:`persona_state` |
||||
raise ValueError("Expected state to be instance of EPersonaState") |
|
||||
|
|
||||
message.body.persona_state = state |
:param persona_state: persona state (Online/Offlane/Away/etc) |
||||
|
:type persona_state: :class:`.EPersonaState` |
||||
|
:param player_name: profile name |
||||
|
:type player_name: :class:`str` |
||||
|
:param persona_state_flags: persona state flags |
||||
|
:type persona_state_flags: :class:`.EPersonaStateFlag` |
||||
|
""" |
||||
|
if not kwargs: return |
||||
|
|
||||
if name: |
self.persona_state = kwargs.get('persona_state', self.persona_state) |
||||
message.body.player_name = name |
|
||||
|
|
||||
|
message = MsgProto(EMsg.ClientChangeStatus) |
||||
|
proto_fill_from_dict(message.body, kwargs) |
||||
self.send(message) |
self.send(message) |
||||
|
Loading…
Reference in new issue