public void AddForeignInventory(SteamID steamId, SteamID botId, int appId, ulong contextId) { Inventory inventory = FetchForeignInventory(steamId, botId, appId, contextId); if (!inventories.HasAppId(appId)) { inventories[appId] = new BotInventories.ContextInventory(); } if (inventory != null && !inventories[appId].HasContextId(contextId)) { inventories[appId].Add(contextId, inventory); } }
public GenericInventory(SteamID steamId, SteamID botId, SteamWeb steamWeb) { ConstructTask = Task.Factory.StartNew(() => { this.steamWeb = steamWeb; string baseInventoryUrl = "http://steamcommunity.com/profiles/" + steamId.ConvertToUInt64() + "/inventory/"; string response = RetryWebRequest(baseInventoryUrl, botId); Regex reg = new Regex("var g_rgAppContextData = (.*?);"); Match m = reg.Match(response); if (m.Success) { try { string json = m.Groups[1].Value; var schemaResult = JsonConvert.DeserializeObject <Dictionary <int, InventoryApps> >(json); foreach (var app in schemaResult) { int appId = app.Key; InventoryTasks[appId] = new InventoryTasks.ContextTask(); foreach (var contextId in app.Value.RgContexts.Keys) { InventoryTasks[appId][contextId] = Task.Factory.StartNew(() => { string inventoryUrl = string.Format("http://steamcommunity.com/profiles/{0}/inventory/json/{1}/{2}/", steamId.ConvertToUInt64(), appId, contextId); var inventory = FetchInventory(inventoryUrl, steamId, botId, appId, contextId); if (!inventories.HasAppId(appId)) { inventories[appId] = new BotInventories.ContextInventory(); } if (inventory != null && !inventories[appId].HasContextId(contextId)) { inventories[appId].Add(contextId, inventory); } }); } } } catch (Exception ex) { Success = false; Console.WriteLine(ex); } } else { Success = false; IsPrivate = true; } }); }