Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load(self, data):
msg, proto_length = struct.unpack_from("
def _parse_message(self, message):
emsg_id, = struct.unpack_from("
def request_password_change_mail(self, password):
"""Request password change mail
:param password: current account password
:type password: :class:`str`
:return: result
:rtype: :class:`.EResult`
"""
message = Msg(EMsg.ClientRequestChangeMail, extended=True)
message.body.password = password
resp = self.send_job_and_wait(message, timeout=10)
if resp is None:
return EResult.Timeout
else:
return EResult(resp.eresult)
def _parse_message(self, message):
emsg_id, = struct.unpack_from("
:type app_ids: :class:`list`
:param package_ids: list of package ids
:type package_ids: :class:`list`
:return: dict with ``apps`` and ``packages`` containing their access tokens, see example below
:rtype: :class:`dict`, :class:`None`
.. code:: python
{'apps': {123: 8888888886, ...},
'packages': {456: 6666666666, ...}
}
"""
if not app_ids and not package_ids:
return
resp = self.send_job_and_wait(MsgProto(EMsg.ClientPICSAccessTokenRequest),
{
'appids': map(int, app_ids),
'packageids': map(int, package_ids),
},
timeout=10
)
if resp:
return {'apps': dict(map(lambda app: (app.appid, app.access_token), resp.app_access_tokens)),
'packages': dict(map(lambda pkg: (pkg.appid, pkg.access_token), resp.package_access_tokens)),
}
def __init__(self, client, logger_name='SteamFriendList'):
self._LOG = logging.getLogger(logger_name)
self._fr = {}
self._steam = client
self._steam.on(EMsg.ClientAddFriendResponse, self._handle_add_friend_result)
self._steam.on(EMsg.ClientFriendsList, self._handle_friends_list)
self._steam.on(self._steam.EVENT_DISCONNECTED, self._handle_disconnect)
def __init__(self, *args, **kwargs):
super(User, self).__init__(*args, **kwargs)
self._user_cache = WeakValueDictionary()
self.on(self.EVENT_DISCONNECTED, self.__handle_disconnect)
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 get_cmsg(emsg):
"""Get protobuf for a given EMsg
:param emsg: EMsg
:type emsg: :class:`steam.enums.emsg.EMsg`, :class:`int`
:return: protobuf message
"""
if not isinstance(emsg, EMsg):
emsg = EMsg(emsg)
if emsg in cmsg_lookup_predefined:
return cmsg_lookup_predefined[emsg]
else:
enum_name = emsg.name.lower()
if enum_name.startswith("econ"): # special case for 'EconTrading_'
enum_name = enum_name[4:]
cmsg_name = "cmsg" + enum_name
return cmsg_lookup.get(cmsg_name, None)
from steam.core.msg.structs import StructMessage as _StructMessage
from google.protobuf.message import Message as _ProtoMessageType
from steam.protobufs import steammessages_base_pb2
from steam.protobufs import steammessages_clientserver_pb2
from steam.protobufs import steammessages_clientserver_2_pb2
from steam.protobufs import steammessages_clientserver_friends_pb2
from steam.protobufs import steammessages_clientserver_login_pb2
cmsg_lookup_predefined = {
EMsg.Multi: steammessages_base_pb2.CMsgMulti,
EMsg.ClientToGC: steammessages_clientserver_2_pb2.CMsgGCClient,
EMsg.ClientFromGC: steammessages_clientserver_2_pb2.CMsgGCClient,
EMsg.ClientServiceMethodLegacy: steammessages_clientserver_2_pb2.CMsgClientServiceMethodLegacy,
EMsg.ClientServiceMethodLegacyResponse: steammessages_clientserver_2_pb2.CMsgClientServiceMethodLegacyResponse,
EMsg.ClientGetNumberOfCurrentPlayersDP: steammessages_clientserver_2_pb2.CMsgDPGetNumberOfCurrentPlayers,
EMsg.ClientGetNumberOfCurrentPlayersDPResponse: steammessages_clientserver_2_pb2.CMsgDPGetNumberOfCurrentPlayersResponse,
# EMsg.ClientEmailChange4: steammessages_clientserver_2_pb2.CMsgClientEmailChange,
# 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()
for proto_module in [
steammessages_clientserver_pb2,
steammessages_clientserver_2_pb2,
steammessages_clientserver_friends_pb2,
steammessages_clientserver_login_pb2,
]:
def __init__(self, protocol=PROTOCOL_TCP):
self.cm_servers = CMServerList()
if protocol == CMClient.PROTOCOL_TCP:
self.connection = TCPConnection()
else:
raise ValueError("Only TCP is supported")
self.on(EMsg.ChannelEncryptRequest, self.__handle_encrypt_request),
self.on(EMsg.Multi, self.__handle_multi),
self.on(EMsg.ClientLogOnResponse, self._handle_logon),
self.on(EMsg.ClientCMList, self._handle_cm_list),