private static void TestBot() { IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .AddJsonFile("appsettings.development.json", true, true) .AddJsonFile("appsettings.production.json", true, true) .Build(); var dataSender = new DataSender(new Uri(config["DataSender:HostName"]), config.GetSection("DataSender:ConnectionMessages").GetChildren().Select(i => i.Value), config["DataSender:MessagePrefix"], config["DataSender:DebugMessagePrefix"], true, config["DataSender:RawMessagePrefix"], config["DataSender:RedtextMessagePrefix"], config["DataSender:RivenImageMessagePrefix"]); var password = GetPassword(config["Credentials:Key"], config["Credentials:Salt"]); var gc = new GameCapture(); //var obs = new ObsSettings() { Url = "ws://*****:*****@"C:\Users\david\AppData\Local\Warframe\Downloaded\Public\Tools\Launcher.exe", new MouseHelper(), new ScreenStateHandler(), gc, null, password, new KeyboardHelper(), new ChatParser(), dataSender, new RivenCleaner(), new RivenParserFactory()); bot.AsyncRun(new System.Threading.CancellationToken()); }
private static void RunBot() { var rivenParser = new RivenParser(); _disposables.Add(rivenParser); //var c = new ChatImageCleaner(JsonConvert.DeserializeObject<CharInfo[]>("chars.json")); Console.WriteLine("Starting up image parser"); var c = new ChatParser(); //var t = new ImageParser(); Console.WriteLine("Loading config for data sender"); IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .AddJsonFile("appsettings.development.json", true, true) .AddJsonFile("appsettings.production.json", true, true) .Build(); Console.WriteLine("Data sender connecting"); var dataSender = new DataSender(new Uri(config["DataSender:HostName"]), config.GetSection("DataSender:ConnectionMessages").GetChildren().Select(i => i.Value), config["DataSender:MessagePrefix"], config["DataSender:DebugMessagePrefix"], true, config["DataSender:RawMessagePrefix"], config["DataSender:RedtextMessagePrefix"], config["DataSender:RivenImageMessagePrefix"], config["DataSender:LogMessagePrefix"], config["DataSender:LogLineMessagePrefix"]); dataSender.RequestToKill += (s, e) => { Console_CancelKeyPress(null, null); }; dataSender.RequestSaveAll += (s, e) => { try { for (int i = 6; i >= 0; i--) { var dir = Path.Combine(config["DEBUG:ImageDirectory"], "Saves"); if (e.Name != null && e.Name.Length > 0) { dir = Path.Combine(config["DEBUG:ImageDirectory"], "Saves", e.Name); } if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var curFile = Path.Combine(config["DEBUG:ImageDirectory"], "capture_" + i + ".png"); var copyFile = Path.Combine(dir, "capture_" + i + ".png"); if (File.Exists(curFile)) { File.Copy(curFile, copyFile, true); } } } catch { } }; var password = GetPassword(config["Credentials:Key"], config["Credentials:Salt"]); var gc = new GameCapture(); var obs = GetObsSettings(config["Credentials:Key"], config["Credentials:Salt"]); var logParser = new WarframeLogParser(); var textParser = new AllTextParser(dataSender, logParser); var bot = new ChatRivenBot(config["LauncherPath"], new MouseHelper(), new ScreenStateHandler(), gc, obs, password, new KeyboardHelper(), new ChatParser(), dataSender, new RivenCleaner(), new RivenParserFactory(), new Application.LogParser.RedTextParser(logParser)); Task t = Task.Run(() => bot.AsyncRun(_cancellationSource.Token)); while (!t.IsCompleted && !t.IsCompleted && !t.IsFaulted) { //var debug = progress.GetAwaiter().IsCompleted; System.Threading.Thread.Sleep(1000); } if (t.IsFaulted || t.Exception != null) { Console.WriteLine("\n" + t.Exception); try { dataSender.AsyncSendDebugMessage(t.Exception.ToString()).Wait(); System.Threading.Thread.Sleep(2000); } catch { } } Dispose(); }