From 11ff450c25552814cb5c0750d270a88b95b781f8 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 25 Aug 2016 15:44:16 -0400 Subject: [PATCH] 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); + } + } + } }