added --accept-all
This commit is contained in:
parent
872cfb50c1
commit
bc46eeba18
1 changed files with 53 additions and 1 deletions
54
Program.cs
54
Program.cs
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -127,6 +126,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;
|
||||
|
@ -351,4 +353,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue