Initial source drop

This commit is contained in:
JustArchi
2015-10-25 06:16:50 +01:00
parent b36ab7220a
commit aa1c1962de
70 changed files with 59852 additions and 0 deletions

58
ArchiSteamFarm/Program.cs Normal file
View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
namespace ArchiSteamFarm {
internal static class Program {
internal const string ConfigDirectoryPath = "config";
private static readonly HashSet<Bot> Bots = new HashSet<Bot>();
internal static readonly object ConsoleLock = new object();
internal static void Exit(int exitCode = 0) {
ShutdownAllBots();
Environment.Exit(exitCode);
}
internal static string GetSteamGuardCode(string botLogin, bool twoFactorAuthentication) {
lock (ConsoleLock) {
if (twoFactorAuthentication) {
Console.Write("<" + botLogin + "> Please enter your 2 factor auth code from your authenticator app: ");
} else {
Console.Write("<" + botLogin + "> Please enter the auth code sent to your email : ");
}
return Console.ReadLine();
}
}
private static void ShutdownAllBots() {
lock (Bots) {
foreach (Bot bot in Bots) {
bot.Stop();
}
Bots.Clear();
}
}
private static void Main(string[] args) {
for (var i = 0; i < 4 && !Directory.Exists(ConfigDirectoryPath); i++) {
Directory.SetCurrentDirectory("..");
}
if (!Directory.Exists(ConfigDirectoryPath)) {
Logging.LogGenericError("Main", "Config directory doesn't exist!");
Console.ReadLine();
Exit(1);
}
lock (Bots) {
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectoryPath, "*.xml")) {
string botName = Path.GetFileNameWithoutExtension(configFile);
Bots.Add(new Bot(botName));
}
}
Thread.Sleep(Timeout.Infinite);
}
}
}