From 0a6843e46ac1e4c068dd02ee9ac30d1623c04924 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 25 Aug 2016 15:27:40 -0400 Subject: [PATCH] Added --trade to list all trade confirmations --- Program.cs | 60 +++++++++++++++++++++++++++++++++++++++++++ steamguard-cli.csproj | 5 +++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index c058c33..2f057d8 100644 --- a/Program.cs +++ b/Program.cs @@ -39,6 +39,8 @@ public static class Program Console.WriteLine("--generate-code Generate a Steam Guard code and exit. (default)"); Console.WriteLine("--encrypt Encrypt your maFiles or change your encryption passkey."); Console.WriteLine("--decrypt Remove encryption from your maFiles."); + Console.WriteLine("--trade List all trade confirmations across all accounts, or of the user\n" + + " specified with --user"); return; } Verbose = args.Contains("-v") || args.Contains("--verbose"); @@ -58,6 +60,10 @@ public static class Program else if (args.Contains("--setup")) { action = "setup"; + } + else if (args.Contains("--trade")) + { + action = "trade"; } // Misc if (args.Contains("--user") || args.Contains("-u")) @@ -112,6 +118,9 @@ public static class Program case "setup": throw new NotSupportedException(); break; + case "trade": + TradeList(user); + break; default: Console.WriteLine("error: Unknown action: {0}", action); return; @@ -220,4 +229,55 @@ public static class Program } return true; } + + static void TradeList(string user = "") + { + if (Verbose) Console.WriteLine("Opening manifest..."); + Manifest = Manifest.GetManifest(true); + if (Verbose) Console.WriteLine("Reading accounts from manifest..."); + if (Manifest.Encrypted) + { + string passkey = Manifest.PromptForPassKey(); + SteamGuardAccounts = Manifest.GetAllAccounts(passkey); + } + else + { + SteamGuardAccounts = Manifest.GetAllAccounts(); + } + if (SteamGuardAccounts.Length == 0) + { + Console.WriteLine("error: No accounts read."); + return; + } + + for (int i = 0; i < SteamGuardAccounts.Length; i++) + { + SteamGuardAccount account = SteamGuardAccounts[i]; + if (user != "") + { + if (account.AccountName.ToLower() == user.ToLower()) + { + showTradeConfirmations(account); + break; + } + } + else + { + showTradeConfirmations(account); + } + } + } + + static void showTradeConfirmations(SteamGuardAccount account) + { + Console.WriteLine($"Checking trade confirmations for {account.AccountName}..."); + if (Verbose) Console.WriteLine("Refeshing Session..."); + account.RefreshSession(); + + Confirmation[] trades = account.FetchConfirmations(); + foreach (var trade in trades) + { + Console.WriteLine($"ID: {trade.ID} Key: {trade.Key} Description: {trade.Description}"); + } + } } diff --git a/steamguard-cli.csproj b/steamguard-cli.csproj index b540346..bd94864 100644 --- a/steamguard-cli.csproj +++ b/steamguard-cli.csproj @@ -52,6 +52,9 @@ .\build\SteamAuth.dll + + ..\..\..\..\..\usr\lib\mono\4.5\System.dll + - + \ No newline at end of file