From 1413f1b359a71fbf114b7f77072895e5c2af3576 Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 7 Oct 2018 16:23:13 -0700 Subject: [PATCH 1/9] Fix crash when attempting to access inventory before calling GetInventory --- SteamBot/Bot.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SteamBot/Bot.cs b/SteamBot/Bot.cs index eee235f83..c11dc9d19 100644 --- a/SteamBot/Bot.cs +++ b/SteamBot/Bot.cs @@ -134,6 +134,10 @@ public Inventory MyInventory { get { + if (myInventoryTask == null) + { + GetInventory(); + } myInventoryTask.Wait(); return myInventoryTask.Result; } From c16778a8bc357c34385758bf2c5c88dde593cbc7 Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 7 Oct 2018 16:23:36 -0700 Subject: [PATCH 2/9] Updated version of SteamAuth --- SteamBot/ExampleBot.csproj | 7 +++---- SteamBot/packages.config | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/SteamBot/ExampleBot.csproj b/SteamBot/ExampleBot.csproj index f8c02e19b..4f142a885 100644 --- a/SteamBot/ExampleBot.csproj +++ b/SteamBot/ExampleBot.csproj @@ -47,9 +47,8 @@ False ..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll - - ..\packages\SteamAuth.2.0.0\lib\net45\SteamAuth.dll - True + + ..\..\packages\SteamAuth.2.0.0\lib\net45\SteamAuth.dll ..\packages\SteamKit2.1.8.1\lib\net45\SteamKit2.dll @@ -107,4 +106,4 @@ - + \ No newline at end of file diff --git a/SteamBot/packages.config b/SteamBot/packages.config index 2456b3bb8..582ecb0cb 100644 --- a/SteamBot/packages.config +++ b/SteamBot/packages.config @@ -4,4 +4,4 @@ - + \ No newline at end of file From fb7003843d997ee2777731228fd5f4ad84753695 Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 7 Oct 2018 16:24:07 -0700 Subject: [PATCH 3/9] Fixed a few crashes, made LoadTask public --- SteamTrade/GenericInventory.cs | 38 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/SteamTrade/GenericInventory.cs b/SteamTrade/GenericInventory.cs index 9a346874c..d549d5fc0 100644 --- a/SteamTrade/GenericInventory.cs +++ b/SteamTrade/GenericInventory.cs @@ -26,9 +26,9 @@ public Dictionary items { get { - if (_loadTask == null) + if (LoadTask == null) return null; - _loadTask.Wait(); + LoadTask.Wait(); return _items; } } @@ -37,9 +37,9 @@ public Dictionary descriptions { get { - if (_loadTask == null) + if (LoadTask == null) return null; - _loadTask.Wait(); + LoadTask.Wait(); return _descriptions; } } @@ -48,16 +48,16 @@ public List errors { get { - if (_loadTask == null) + if (LoadTask == null) return null; - _loadTask.Wait(); + LoadTask.Wait(); return _errors; } } public bool isLoaded = false; - private Task _loadTask; + public Task LoadTask { get; private set; } private Dictionary _descriptions = new Dictionary(); private Dictionary _items = new Dictionary(); private List _errors = new List(); @@ -113,9 +113,9 @@ public void debug_app_data() /// public ItemDescription getDescription(ulong id) { - if (_loadTask == null) + if (LoadTask == null) return null; - _loadTask.Wait(); + LoadTask.Wait(); try { @@ -130,7 +130,7 @@ public ItemDescription getDescription(ulong id) public void load(int appid, IEnumerable contextIds, SteamID steamid) { List contextIdsCopy = contextIds.ToList(); - _loadTask = Task.Factory.StartNew(() => loadImplementation(appid, contextIdsCopy, steamid)); + LoadTask = Task.Factory.StartNew(() => loadImplementation(appid, contextIdsCopy, steamid)); } public void loadImplementation(int appid, IEnumerable contextIds, SteamID steamid) @@ -171,7 +171,7 @@ public void loadImplementation(int appid, IEnumerable contextIds, SteamID if (!_items.ContainsKey(id)) { string descriptionid = itemId.classid + "_" + itemId.instanceid; - _items.Add((ulong)itemId.id, new Item(appid, contextId, (ulong)itemId.id, descriptionid)); + _items.Add((ulong) itemId.id, new Item(appid, contextId, (ulong) itemId.id, descriptionid)); break; } } @@ -185,10 +185,10 @@ public void loadImplementation(int appid, IEnumerable contextIds, SteamID string key = "" + (class_instance.classid ?? '0') + "_" + (class_instance.instanceid ?? '0'); if (!_descriptions.ContainsKey(key)) { - if(class_instance.app_data != null) + if (class_instance.app_data != null) { tmpAppData = new Dictionary(); - foreach(var value in class_instance.app_data) + foreach (var value in class_instance.app_data) { tmpAppData.Add("" + value.Name, "" + value.Value); } @@ -203,10 +203,12 @@ public void loadImplementation(int appid, IEnumerable contextIds, SteamID { name = class_instance.name, type = class_instance.type, - marketable = (bool)class_instance.marketable, - tradable = (bool)class_instance.tradable, - classid = long.Parse((string)class_instance.classid), - url = (class_instance.actions != null && class_instance.actions.First["link"] != null ? class_instance.actions.First["link"] : ""), + marketable = (bool) class_instance.marketable, + tradable = (bool) class_instance.tradable, + classid = String.IsNullOrEmpty((string)class_instance.classid) ? -1 : long.Parse((string) class_instance.classid), + url = (class_instance.actions != null && class_instance.actions.First["link"] != null + ? class_instance.actions.First["link"] + : ""), app_data = tmpAppData, market_fee_app_id = (class_instance.market_fee_app != null ? class_instance.market_fee_app : 0), } @@ -225,7 +227,7 @@ public void loadImplementation(int appid, IEnumerable contextIds, SteamID { moreStart = null; } - } while (!String.IsNullOrEmpty(moreStart) && moreStart.ToLower() != "false"); + } while (!String.IsNullOrEmpty(moreStart) && moreStart.ToLower() != "false" && moreStart != "0"); }//end for (contextId) }//end try catch (Exception e) From eb1349815e6801630c845f6ca7280d560433e65c Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 7 Oct 2018 16:24:39 -0700 Subject: [PATCH 4/9] Updated SteamAuth again --- SteamTrade/SteamTrade.csproj | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/SteamTrade/SteamTrade.csproj b/SteamTrade/SteamTrade.csproj index 52347259c..5baf6c7e5 100644 --- a/SteamTrade/SteamTrade.csproj +++ b/SteamTrade/SteamTrade.csproj @@ -44,10 +44,6 @@ ..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll - - ..\packages\SteamAuth.2.0.0\lib\net45\SteamAuth.dll - True - ..\packages\SteamKit2.1.8.1\lib\net45\SteamKit2.dll True @@ -82,4 +78,4 @@ - + \ No newline at end of file From 42892d53103837c62bccefc4f1f89c685a1a48ee Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 7 Oct 2018 16:38:39 -0700 Subject: [PATCH 5/9] Default to 2FA in example program --- SteamBot/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SteamBot/Program.cs b/SteamBot/Program.cs index 6246ce039..cb85b2e0b 100644 --- a/SteamBot/Program.cs +++ b/SteamBot/Program.cs @@ -74,7 +74,7 @@ private static void BotMode(int botIndex) return; } - Bot b = new Bot(configObject.Bots[botIndex], configObject.ApiKey, BotManager.UserHandlerCreator, true, true); + Bot b = new Bot(configObject.Bots[botIndex], configObject.ApiKey, BotManager.UserHandlerCreator, true, true, true); Console.Title = "Bot Manager"; b.StartBot(); From 96498f842b20fc8d4e9e8b5391cf6f2b2be906cd Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 7 Oct 2018 18:34:29 -0700 Subject: [PATCH 6/9] Update package versions --- SteamBot/Bot.cs | 2 +- SteamBot/ExampleBot.csproj | 14 ++++++-------- SteamBot/app.config | 2 +- SteamBot/packages.config | 6 +++--- SteamTrade/SteamTrade.csproj | 13 +++++++------ SteamTrade/app.config | 2 +- SteamTrade/packages.config | 8 ++++---- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/SteamBot/Bot.cs b/SteamBot/Bot.cs index 5ee307433..c797c1e54 100644 --- a/SteamBot/Bot.cs +++ b/SteamBot/Bot.cs @@ -813,7 +813,7 @@ public void AcceptAllMobileTradeConfirmations() { if (SteamGuardAccount.AcceptConfirmation(confirmation)) { - Log.Success("Confirmed {0}. (Confirmation ID #{1})", confirmation.Description, confirmation.ID); + Log.Success("Confirmed {0}. (Confirmation ID #{1})", confirmation.Key, confirmation.ID); } } } diff --git a/SteamBot/ExampleBot.csproj b/SteamBot/ExampleBot.csproj index 4f142a885..4445c9a0c 100644 --- a/SteamBot/ExampleBot.csproj +++ b/SteamBot/ExampleBot.csproj @@ -39,20 +39,18 @@ true - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True + + ..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll False ..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll - - ..\..\packages\SteamAuth.2.0.0\lib\net45\SteamAuth.dll + + ..\..\packages\SteamAuth.3.0.0\lib\net45\SteamAuth.dll - - ..\packages\SteamKit2.1.8.1\lib\net45\SteamKit2.dll - True + + ..\..\packages\SteamKit2.1.8.3\lib\net45\SteamKit2.dll diff --git a/SteamBot/app.config b/SteamBot/app.config index 505627df2..b003b7f94 100644 --- a/SteamBot/app.config +++ b/SteamBot/app.config @@ -8,7 +8,7 @@ - + diff --git a/SteamBot/packages.config b/SteamBot/packages.config index 582ecb0cb..799f35ac9 100644 --- a/SteamBot/packages.config +++ b/SteamBot/packages.config @@ -1,7 +1,7 @@  - + - - + + \ No newline at end of file diff --git a/SteamTrade/SteamTrade.csproj b/SteamTrade/SteamTrade.csproj index 5baf6c7e5..1876df77e 100644 --- a/SteamTrade/SteamTrade.csproj +++ b/SteamTrade/SteamTrade.csproj @@ -37,16 +37,17 @@ false - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True + + ..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll ..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll - - ..\packages\SteamKit2.1.8.1\lib\net45\SteamKit2.dll - True + + ..\..\packages\SteamAuth.3.0.0\lib\net45\SteamAuth.dll + + + ..\..\packages\SteamKit2.1.8.3\lib\net45\SteamKit2.dll diff --git a/SteamTrade/app.config b/SteamTrade/app.config index 05d974bf6..701f86759 100644 --- a/SteamTrade/app.config +++ b/SteamTrade/app.config @@ -4,7 +4,7 @@ - + diff --git a/SteamTrade/packages.config b/SteamTrade/packages.config index 2456b3bb8..799f35ac9 100644 --- a/SteamTrade/packages.config +++ b/SteamTrade/packages.config @@ -1,7 +1,7 @@  - + - - - + + + \ No newline at end of file From 3631b8bc3a7c19e3cb846508fb0834e7e95337f7 Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 7 Oct 2018 18:34:43 -0700 Subject: [PATCH 7/9] Small cleanup --- SteamTrade/GenericInventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SteamTrade/GenericInventory.cs b/SteamTrade/GenericInventory.cs index d549d5fc0..a689ef2e5 100644 --- a/SteamTrade/GenericInventory.cs +++ b/SteamTrade/GenericInventory.cs @@ -223,7 +223,7 @@ public void loadImplementation(int appid, IEnumerable contextIds, SteamID { moreStart = invResponse.more_start; } - catch (Exception e) + catch (Exception) { moreStart = null; } From 3ab4c194e945bf7ea7713e9fb8d831416a337a05 Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 7 Oct 2018 18:34:57 -0700 Subject: [PATCH 8/9] BUGFIX: Use https when fetching confirmations --- SteamTrade/TradeWebAPI/TradeSession.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SteamTrade/TradeWebAPI/TradeSession.cs b/SteamTrade/TradeWebAPI/TradeSession.cs index e5255b69c..c7c9ac188 100644 --- a/SteamTrade/TradeWebAPI/TradeSession.cs +++ b/SteamTrade/TradeWebAPI/TradeSession.cs @@ -12,7 +12,7 @@ namespace SteamTrade.TradeWebAPI /// public class TradeSession { - private const string SteamTradeUrl = "http://steamcommunity.com/trade/{0}/"; + private const string SteamTradeUrl = "https://steamcommunity.com/trade/{0}/"; private string sessionIdEsc; private string baseTradeURL; From 990167be6352ada3090f7e91d2af116625c5f751 Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Mon, 10 Dec 2018 04:23:14 -0800 Subject: [PATCH 9/9] Accept upper+lower case hex digits --- SteamTrade/SteamWeb.cs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/SteamTrade/SteamWeb.cs b/SteamTrade/SteamWeb.cs index 806a13038..76cf89b46 100644 --- a/SteamTrade/SteamWeb.cs +++ b/SteamTrade/SteamWeb.cs @@ -2,6 +2,7 @@ using System.IO; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Net; using System.Net.Cache; using System.Text; @@ -464,26 +465,9 @@ private byte[] HexToByte(string hex) throw new Exception("The binary key cannot have an odd number of digits"); } - byte[] arr = new byte[hex.Length >> 1]; - int l = hex.Length; - - for (int i = 0; i < (l >> 1); ++i) - { - arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1]))); - } - - return arr; - } - - /// - /// Get the Hex value as int out of an char. - /// - /// Input parameter. - /// A Hex Value as int. - private int GetHexVal(char hex) - { - int val = hex; - return val - (val < 58 ? 48 : 55); + return Enumerable.Range(0, hex.Length / 2) + .Select(x => Convert.ToByte(hex.Substring(x*2, 2), 16)) + .ToArray(); } ///