Browse Source

update SteamClient to use new chat mode

pull/202/head
Rossen Georgiev 6 years ago
parent
commit
8dec921a59
  1. 1
      CHANGES.md
  2. 4
      steam/client/__init__.py
  3. 8
      steam/client/builtins/user.py
  4. 19
      steam/client/user.py
  5. 1
      steam/core/msg/__init__.py

1
CHANGES.md

@ -26,3 +26,4 @@ This release brings some breaking changes
- Messages now have a payload property set when the body cannot be parsed
- Updated protocol version to 65580
- Added `CDNClient`
- Update `SteamClient` to use new chat mode

4
steam/client/__init__.py

@ -54,6 +54,7 @@ class SteamClient(CMClient, BuiltinBase):
credential_location = None #: location for sentry
username = None #: username when logged on
login_key = None #: can be used for subsequent logins (no 2FA code will be required)
chat_mode = 2 #: chat mode (0=old chat, 2=new chat)
def __init__(self):
CMClient.__init__(self)
@ -533,8 +534,7 @@ class SteamClient(CMClient, BuiltinBase):
message.body.client_language = "english"
message.body.should_remember_password = True
message.body.supports_rate_limit_response = True
message.body.ui_mode = 0
message.body.chat_mode = 2
message.body.chat_mode = self.chat_mode
if login_id is None:
message.body.obfustucated_private_ip = ip_to_int(self.connection.local_address) ^ 0xF00DBAAD

8
steam/client/builtins/user.py

@ -28,12 +28,20 @@ class User(object):
self.on(self.EVENT_LOGGED_ON, self.__handle_set_persona)
self.on(EMsg.ClientPersonaState, self.__handle_persona_state)
self.on(EMsg.ClientFriendMsgIncoming, self.__handle_message_incoming)
self.on("FriendMessagesClient.IncomingMessage#1", self.__handle_message_incoming2)
def __handle_message_incoming(self, msg):
# old chat
if msg.body.chat_entry_type == EChatEntryType.ChatMsg:
user = self.get_user(msg.body.steamid_from)
self.emit("chat_message", user, msg.body.message.decode('utf-8'))
def __handle_message_incoming2(self, msg):
# new chat
if msg.body.chat_entry_type == EChatEntryType.ChatMsg:
user = self.get_user(msg.body.steamid_friend)
self.emit("chat_message", user, msg.body.message)
def __handle_disconnect(self):
self.user = None
self.current_games_played = []

19
steam/client/user.py

@ -112,8 +112,17 @@ class SteamUser(object):
:param message: message to send
:type message: str
"""
self._steam.send(MsgProto(EMsg.ClientFriendMsg), {
'steamid': self.steam_id,
'chat_entry_type': EChatEntryType.ChatMsg,
'message': message.encode('utf8'),
})
# new chat
if self._steam.chat_mode == 2:
self._steam.send_um("FriendMessages.SendMessage#1", {
'steamid': self.steam_id,
'message': message,
'chat_entry_type': EChatEntryType.ChatMsg,
})
# old chat
else:
self._steam.send(MsgProto(EMsg.ClientFriendMsg), {
'steamid': self.steam_id,
'chat_entry_type': EChatEntryType.ChatMsg,
'message': message.encode('utf8'),
})

1
steam/core/msg/__init__.py

@ -24,6 +24,7 @@ cmsg_lookup_predefined = {
# EMsg.ClientEmailChangeResponse4: steammessages_clientserver_2_pb2.CMsgClientEmailChangeResponse,
EMsg.ClientLogonGameServer: steammessages_clientserver_login_pb2.CMsgClientLogon,
EMsg.ClientCurrentUIMode: steammessages_clientserver_2_pb2.CMsgClientUIMode,
EMsg.ClientChatOfflineMessageNotification: steammessages_clientserver_2_pb2.CMsgClientOfflineMessageNotification,
}
cmsg_lookup = dict()

Loading…
Cancel
Save