Added --trade to list all trade confirmations

This commit is contained in:
Carson McManus 2016-08-25 15:27:40 -04:00
parent 007588de38
commit 872cfb50c1
2 changed files with 59 additions and 1 deletions

View file

@ -103,6 +103,7 @@ public static class Program
return; return;
} }
} }
if (Verbose) Console.WriteLine("maFiles path: {0}", SteamGuardPath);
if (Verbose) Console.WriteLine($"Action: {action}"); if (Verbose) Console.WriteLine($"Action: {action}");
if (Verbose) Console.WriteLine($"User: {user}"); if (Verbose) Console.WriteLine($"User: {user}");
@ -123,6 +124,9 @@ public static class Program
case "setup": case "setup":
throw new NotSupportedException(); throw new NotSupportedException();
break; break;
case "trade":
TradeList(user);
break;
default: default:
Console.WriteLine("error: Unknown action: {0}", action); Console.WriteLine("error: Unknown action: {0}", action);
return; return;
@ -296,4 +300,55 @@ public static class Program
} }
return true; 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}");
}
}
} }

View file

@ -52,6 +52,9 @@
<Reference Include="SteamAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="SteamAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>.\build\SteamAuth.dll</HintPath> <HintPath>.\build\SteamAuth.dll</HintPath>
</Reference> </Reference>
<Reference Include="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<HintPath>..\..\..\..\..\usr\lib\mono\4.5\System.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@ -61,4 +64,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>