Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_account_id_to_steam_id(self):
account_id = '358617487'
steam_id = utils.account_id_to_steam_id(account_id)
self.assertEqual('76561198318883215', steam_id)
def test_make_offer_url(self):
partner_account_id = '32384925'
partner_token = '7vqRtBpC'
sample_trade_url = 'https://steamcommunity.com/tradeoffer/new/?partner=' + partner_account_id + '&token=' + partner_token
client = SteamClient(self.credentials.api_key)
client.login(self.credentials.login, self.credentials.password, self.steam_guard_file)
client._session.request('HEAD', 'http://steamcommunity.com')
partner_steam_id = account_id_to_steam_id(partner_account_id)
game = GameOptions.CS
my_items = client.get_my_inventory(game, merge=False)['rgInventory']
partner_items = client.get_partner_inventory(partner_steam_id, game, merge=False)['rgInventory']
my_first_item = next(iter(my_items.values()))
partner_first_item = next(iter(partner_items.values()))
my_asset = Asset(my_first_item['id'], game)
partner_asset = Asset(partner_first_item['id'], game)
response = client.make_offer_with_url([my_asset], [partner_asset], sample_trade_url, 'TESTOWA OFERTA')
self.assertIsNotNone(response)
self.assertIn('tradeofferid', response.keys())
def fetch_messages(self) -> dict:
message_list = {
'sent': [],
'received': []
}
events = self.poll_events()
if not events:
return message_list
messages = events["messages"]
for message in messages:
text = message.get("text")
if message['type'] == "saytext":
accountid_from = account_id_to_steam_id(message.get("accountid_from"))
message_list['received'].append({"partner": accountid_from, "message": text})
elif message['type'] == "my_saytext":
accountid_from = account_id_to_steam_id(message.get("accountid_from"))
message_list['sent'].append({"partner": accountid_from, "message": text})
return message_list
def make_offer_with_url(self, items_from_me: List[Asset], items_from_them: List[Asset],
trade_offer_url: str, message: str = '', case_sensitive: bool=True) -> dict:
token = get_key_value_from_url(trade_offer_url, 'token', case_sensitive)
partner_account_id = get_key_value_from_url(trade_offer_url, 'partner', case_sensitive)
partner_steam_id = account_id_to_steam_id(partner_account_id)
offer = self._create_offer_dict(items_from_me, items_from_them)
session_id = self._get_session_id()
url = SteamUrl.COMMUNITY_URL + '/tradeoffer/new/send'
server_id = 1
trade_offer_create_params = {'trade_offer_access_token': token}
params = {
'sessionid': session_id,
'serverid': server_id,
'partner': partner_steam_id,
'tradeoffermessage': message,
'json_tradeoffer': json.dumps(offer),
'captcha': '',
'trade_offer_create_params': json.dumps(trade_offer_create_params)
}
headers = {'Referer': SteamUrl.COMMUNITY_URL + urlparse.urlparse(trade_offer_url).path,
'Origin': SteamUrl.COMMUNITY_URL}