From 0a6843e46ac1e4c068dd02ee9ac30d1623c04924 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 25 Aug 2016 15:27:40 -0400 Subject: [PATCH 1/2] 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 From 11ff450c25552814cb5c0750d270a88b95b781f8 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 25 Aug 2016 15:44:16 -0400 Subject: [PATCH 2/2] added --accept-all --- Program.cs | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index 2f057d8..12c38b1 100644 --- a/Program.cs +++ b/Program.cs @@ -41,7 +41,9 @@ public static class Program 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; + Console.WriteLine("--accept-all Accept all trade confirmations on all accounts, or all confirmations of\n" + + " the user specified with --user."); + return; } Verbose = args.Contains("-v") || args.Contains("--verbose"); // Actions @@ -64,6 +66,10 @@ public static class Program else if (args.Contains("--trade")) { action = "trade"; + } + else if (args.Contains("--accept-all")) + { + action = "accept-all"; } // Misc if (args.Contains("--user") || args.Contains("-u")) @@ -121,6 +127,9 @@ public static class Program case "trade": TradeList(user); break; + case "accept-all": + AcceptAllTrades(user); + break; default: Console.WriteLine("error: Unknown action: {0}", action); return; @@ -280,4 +289,54 @@ public static class Program Console.WriteLine($"ID: {trade.ID} Key: {trade.Key} Description: {trade.Description}"); } } + + static void AcceptAllTrades(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()) + { + Console.WriteLine($"Accepting Confirmations on {account.AccountName}"); + if (Verbose) Console.WriteLine("Refeshing Session..."); + account.RefreshSession(); + if (Verbose) Console.WriteLine("Fetching Confirmations..."); + Confirmation[] confirmations = account.FetchConfirmations(); + if (Verbose) Console.WriteLine("Accepting Confirmations..."); + account.AcceptMultipleConfirmations(confirmations); + break; + } + } + else + { + Console.WriteLine($"Accepting Confirmations on {account.AccountName}"); + if (Verbose) Console.WriteLine("Refeshing Session..."); + account.RefreshSession(); + if (Verbose) Console.WriteLine("Fetching Confirmations..."); + Confirmation[] confirmations = account.FetchConfirmations(); + if (Verbose) Console.WriteLine("Accepting Confirmations..."); + account.AcceptMultipleConfirmations(confirmations); + } + } + } }