예제 #1
0
		internal Statistics(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException(nameof(bot));
			}

			Bot = bot;
		}
예제 #2
0
		internal ArchiHandler(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException(nameof(bot));
			}

			Bot = bot;
		}
예제 #3
0
		internal ArchiWebHandler(Bot bot, string apiKey) {
			Bot = bot;

			if (!string.IsNullOrEmpty(apiKey) && !apiKey.Equals("null")) {
				ApiKey = apiKey;
			}
		}
예제 #4
0
		internal Trading(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException(nameof(bot));
			}

			Bot = bot;
		}
예제 #5
0
		internal ArchiWebHandler(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException(nameof(bot));
			}

			Bot = bot;

			WebBrowser = new WebBrowser(bot.ArchiLogger);
		}
예제 #6
0
		internal ArchiWebHandler(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException("bot");
			}

			Bot = bot;

			WebBrowser = new WebBrowser(bot.BotName);
		}
예제 #7
0
		internal CardsFarmer(Bot bot) {
			Bot = bot;

			Timer = new Timer(
				async e => await CheckGamesForFarming().ConfigureAwait(false),
				null,
				TimeSpan.FromMinutes(15), // Delay
				TimeSpan.FromMinutes(15) // Period
			);
		}
예제 #8
0
		internal static void OnStateUpdated(Bot bot, SteamFriends.PersonaStateCallback callback) {
			if ((bot == null) || (callback == null)) {
				Logging.LogNullError(nameof(bot) + " || " + nameof(callback));
				return;
			}

			BotStatusForm form;
			if (!BotStatusForm.BotForms.TryGetValue(bot.BotName, out form)) {
				return;
			}

			form.OnStateUpdated(callback);
		}
예제 #9
0
		internal BotStatusForm(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException(nameof(bot));
			}

			Bot = bot;

			BotForms[bot.BotName] = this;

			InitializeComponent();

			Dock = DockStyle.Fill;
		}
예제 #10
0
		internal CardsFarmer(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException("bot");
			}

			Bot = bot;

			if (Timer == null && Program.GlobalConfig.IdleFarmingPeriod > 0) {
				Timer = new Timer(
					async e => await CheckGamesForFarming().ConfigureAwait(false),
					null,
					TimeSpan.FromHours(Program.GlobalConfig.IdleFarmingPeriod), // Delay
					TimeSpan.FromHours(Program.GlobalConfig.IdleFarmingPeriod) // Period
				);
			}
		}
예제 #11
0
		internal CardsFarmer(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException(nameof(bot));
			}

			Bot = bot;

			if (Program.GlobalConfig.IdleFarmingPeriod > 0) {
				IdleFarmingTimer = new Timer(
					e => CheckGamesForFarming(),
					null,
					TimeSpan.FromHours(Program.GlobalConfig.IdleFarmingPeriod) + TimeSpan.FromMinutes(0.5 * Bot.Bots.Count), // Delay
					TimeSpan.FromHours(Program.GlobalConfig.IdleFarmingPeriod) // Period
				);
			}
		}
예제 #12
0
		internal CardsFarmer(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException(nameof(bot));
			}

			Bot = bot;

			if ((Timer == null) && (Program.GlobalConfig.IdleFarmingPeriod > 0)) {
				Timer = new Timer(
					e => CheckGamesForFarming(),
					null,
					TimeSpan.FromHours(Program.GlobalConfig.IdleFarmingPeriod), // Delay
					TimeSpan.FromHours(Program.GlobalConfig.IdleFarmingPeriod) // Period
				);
			}
		}
예제 #13
0
        internal static void OnPersonaState(Bot bot, SteamFriends.PersonaStateCallback callback)
        {
            if (bot == null) {
                ASF.ArchiLogger.LogNullError(nameof(bot));
                return;
            }

            if (callback == null) {
                bot.ArchiLogger.LogNullError(nameof(callback));
                return;
            }

            BotStatusForm form;
            if (!BotStatusForm.BotForms.TryGetValue(bot.BotName, out form)) {
                return;
            }

            form.OnStateUpdated(callback);
        }
예제 #14
0
		internal Trading(Bot bot) {
			Bot = bot;
		}
예제 #15
0
		private async void MainForm_Load(object sender, EventArgs e) {
			Logging.InitFormLogger();

			BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList;

			await Task.Run(async () => {
				ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);

				if (!Directory.Exists(SharedInfo.ConfigDirectory)) {
					ASF.ArchiLogger.LogGenericError("Config directory could not be found!");
					Environment.Exit(1);
				}

				await ASF.CheckForUpdate().ConfigureAwait(false);

				// Before attempting to connect, initialize our list of CMs
				Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider);
			});

			foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) {
				switch (botName) {
					case SharedInfo.ASF:
					case "example":
					case "minimal":
						continue;
				}

				Bot bot = new Bot(botName);

				BotStatusForm botStatusForm = new BotStatusForm(bot);

				BotIndexes[botName] = AvatarImageList.Images.Count;

				AvatarImageList.Images.Add(botName, botStatusForm.AvatarPictureBox.Image);

				botStatusForm.TopLevel = false;
				BotStatusPanel.Controls.Add(botStatusForm);

				ListViewItem botListViewItem = new ListViewItem {
					ImageIndex = BotIndexes[botName],
					Text = botName
				};

				BotListView.Items.Add(botListViewItem);
			}

			if (BotListView.Items.Count > 0) {
				BotListView.Items[0].Selected = true;
				BotListView.Select();
			}
		}
예제 #16
0
 public string GetStatus() => Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus(Bot.Bots);
예제 #17
0
 internal Actions([NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
예제 #18
0
		internal void Init(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
예제 #19
0
		private static void Init(IEnumerable<string> args) {
			AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
			TaskScheduler.UnobservedTaskException += UnobservedTaskExceptionHandler;

			Logging.LogGenericInfo("ASF V" + Version);
			Directory.SetCurrentDirectory(ExecutableDirectory);
			InitServices();

			// Allow loading configs from source tree if it's a debug build
			if (Debugging.IsDebugBuild) {

				// Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
				for (byte i = 0; i < 4; i++) {
					Directory.SetCurrentDirectory("..");
					if (Directory.Exists(ConfigDirectory)) {
						break;
					}
				}

				// If config directory doesn't exist after our adjustment, abort all of that
				if (!Directory.Exists(ConfigDirectory)) {
					Directory.SetCurrentDirectory(ExecutableDirectory);
				}
			}

			// If debugging is on, we prepare debug directory prior to running
			if (GlobalConfig.Debug) {
				if (Directory.Exists(DebugDirectory)) {
					Directory.Delete(DebugDirectory, true);
					Thread.Sleep(1000); // Dirty workaround giving Windows some time to sync
				}
				Directory.CreateDirectory(DebugDirectory);

				SteamKit2.DebugLog.AddListener(new Debugging.DebugListener(Path.Combine(DebugDirectory, "debug.txt")));
				SteamKit2.DebugLog.Enabled = true;
			}

			// Parse args
			if (args != null) {
				ParseArgs(args);
			}

			// If we ran ASF as a client, we're done by now
			if (Mode == EMode.Client) {
				Exit();
			}

			// From now on it's server mode
			Logging.Init();

			if (!Directory.Exists(ConfigDirectory)) {
				Logging.LogGenericError("Config directory doesn't exist!");
				Thread.Sleep(5000);
				Exit(1);
			}

			CheckForUpdate().Wait();

			// Before attempting to connect, initialize our list of CMs
			Bot.RefreshCMs(GlobalDatabase.CellID).Wait();

			bool isRunning = false;

			foreach (string botName in Directory.EnumerateFiles(ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) {
				switch (botName) {
					case ASF:
					case "example":
					case "minimal":
						continue;
				}

				Bot bot = new Bot(botName);
				if ((bot.BotConfig == null) || !bot.BotConfig.Enabled) {
					continue;
				}

				if (bot.BotConfig.StartOnLaunch) {
					isRunning = true;
				}
			}

			// Check if we got any bots running
			if (!isRunning) {
				OnBotShutdown();
			}
		}
예제 #20
0
 internal Actions([JetBrains.Annotations.NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
예제 #21
0
 internal Statistics(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
예제 #22
0
		private static void Main(string[] args) {
			Logging.LogGenericInfo("Main", "Archi's Steam Farm, version " + Version);

			Task.Run(async () => await CheckForUpdate().ConfigureAwait(false)).Wait();

			// Config directory may not be in the same directory as the .exe, check maximum of 3 levels lower
			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);
					Bot bot = new Bot(botName);
					Bots.Add(bot);
					if (!bot.Enabled) {
						Logging.LogGenericInfo(botName, "Not starting this instance because it's disabled in config file");
					}
				}
			}

			Thread.Sleep(Timeout.Infinite);
		}
예제 #23
0
		private static void Main(string[] args) {
			AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);

			Logging.LogGenericInfo("Main", "Archi's Steam Farm, version " + Version);
			Directory.SetCurrentDirectory(ExecutableDirectory);
			InitServices();

			// Allow loading configs from source tree if it's a debug build
			if (Debugging.IsDebugBuild) {

				// Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
				for (var i = 0; i < 4; i++) {
					Directory.SetCurrentDirectory("..");
					if (Directory.Exists(ConfigDirectory)) {
						break;
					}
				}

				// If config directory doesn't exist after our adjustment, abort all of that
				if (!Directory.Exists(ConfigDirectory)) {
					Directory.SetCurrentDirectory(ExecutableDirectory);
				}
			}

			// By default we're operating on normal mode
			Mode = EMode.Normal;
			Logging.LogToFile = true;

			// But that can be overriden by arguments
			ParseArgs(args);

			// If we ran ASF as a client, we're done by now
			if (Mode == EMode.Client) {
				return;
			}

			Task.Run(async () => await CheckForUpdate().ConfigureAwait(false)).Wait();

			if (!Directory.Exists(ConfigDirectory)) {
				Logging.LogGenericError("Main", "Config directory doesn't exist!");
				Thread.Sleep(5000);
				Task.Run(async () => await Exit(1).ConfigureAwait(false)).Wait();
			}

			foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.xml")) {
				string botName = Path.GetFileNameWithoutExtension(configFile);
				Bot bot = new Bot(botName);
				if (!bot.Enabled) {
					Logging.LogGenericInfo(botName, "Not starting this instance because it's disabled in config file");
				}
			}

			// Check if we got any bots running
			OnBotShutdown();

			// Wait for signal to shutdown
			ShutdownResetEvent.WaitOne();

			// We got a signal to shutdown, consider giving user some time to read the message
			Thread.Sleep(5000);

			// This is over, cleanup only now
			WCF.StopServer();
		}
		internal void Init(Bot bot) {
			if (bot == null) {
				throw new ArgumentNullException(nameof(bot));
			}

			Bot = bot;
		}
예제 #25
0
		internal static void OnStateUpdated(Bot bot, SteamFriends.PersonaStateCallback callback) {
		}
예제 #26
0
		internal CardsFarmer(Bot bot) {
			Bot = bot;
		}
예제 #27
0
 internal Trading(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));