internal Statistics(Bot bot) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } Bot = bot; }
internal ArchiHandler(Bot bot) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } Bot = bot; }
internal ArchiWebHandler(Bot bot, string apiKey) { Bot = bot; if (!string.IsNullOrEmpty(apiKey) && !apiKey.Equals("null")) { ApiKey = apiKey; } }
internal Trading(Bot bot) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } Bot = bot; }
internal ArchiWebHandler(Bot bot) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } Bot = bot; WebBrowser = new WebBrowser(bot.ArchiLogger); }
internal ArchiWebHandler(Bot bot) { if (bot == null) { throw new ArgumentNullException("bot"); } Bot = bot; WebBrowser = new WebBrowser(bot.BotName); }
internal CardsFarmer(Bot bot) { Bot = bot; Timer = new Timer( async e => await CheckGamesForFarming().ConfigureAwait(false), null, TimeSpan.FromMinutes(15), // Delay TimeSpan.FromMinutes(15) // Period ); }
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); }
internal BotStatusForm(Bot bot) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } Bot = bot; BotForms[bot.BotName] = this; InitializeComponent(); Dock = DockStyle.Fill; }
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 ); } }
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 ); } }
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 ); } }
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); }
internal Trading(Bot bot) { Bot = bot; }
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(); } }
public string GetStatus() => Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus(Bot.Bots);
internal Actions([NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
internal void Init(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
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(); } }
internal Actions([JetBrains.Annotations.NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
internal Statistics(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
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); }
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; }
internal static void OnStateUpdated(Bot bot, SteamFriends.PersonaStateCallback callback) { }
internal CardsFarmer(Bot bot) { Bot = bot; }
internal Trading(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));