void ConfigureDatabase() { while (true) { string provider = ""; if (string.IsNullOrWhiteSpace(DiceBot.PersonalSettings.EncrConnectionString)) { Console.WriteLine("It seems like this is the first time you're running DiceBot. Please configure a database to store your bets in.\n"); } Console.WriteLine("(1) SQLite (Default)\n(2) MS SQL Server\n(3) MYSQL\n(4) Mongo\n(5) Post Gre\n\nSelect database provider:"); string input = Console.ReadLine(); switch (input) { case "1": default: provider = "SQLite"; break; case "2": provider = "MSSQL"; break; case "3": provider = "MYSQL"; break; case "4": provider = "Mongo"; break; case "5": provider = "PostGRE"; break; } Console.WriteLine("Selected Provider: " + provider); Console.WriteLine("Please provide the following DB settings:"); Console.Write("Data Source (File name or database server): "); string datasource = Console.ReadLine(); string Constring = ""; if (input != "1") { Console.Write("Initial Catalog (Database name):"); string dbname = Console.ReadLine(); Console.Write("DB Username: "******"DB Password: "******"Data Source={0};Initial Catalog={1};User Id={2};Password={3};persist security info=true;", datasource, dbname, Username, Password); DiceBot.PersonalSettings.Provider = provider; } else { Constring = string.Format("Data Source={0};Version=3;Compress=True;", datasource); DiceBot.PersonalSettings.Provider = provider; } Console.WriteLine("Enter a password to encrypt your connection string. You will need to enter it every time you open DiceBot. Leaving it blank will store your connectionstring in plain text."); Console.Write("Password: "******"personalsettings.json"); DiceBot.LoadPersonalSettings("personalsettings.json"); return; } }
private void bchk_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) { GlobalSettings tmp = new GlobalSettings(); Doormat botins = new Doormat(); botins.LoadPersonalSettings(Path + "personalsettings.json"); tmp.Settings = botins.PersonalSettings; //tmp.Settings = personal settings instance being used? tmp.Show(); }
public Task <object> CreateInstance(IDictionary <string, object> input) { using (StreamWriter x = File.AppendText("test.txt")) { x.WriteLine(input); foreach (PropertyInfo y in input.GetType().GetProperties()) { x.WriteLine(y.Name); } x.WriteLine(input["OnGameChanged"]); } if (Instance == null) { Logger.LoggingLevel = 6; Instance = new Doormat(); Callbacks = new Dictionary <string, Func <object, Task <object> > >(); Instance.OnGameChanged += Instance_OnGameChanged; Callbacks.Add("OnGameChanged", (Func <object, Task <object> >)input["OnGameChanged"]); Instance.OnSiteAction += Instance_OnSiteAction; Callbacks.Add("OnSiteAction", (Func <object, Task <object> >)input["OnSiteAction"]); Instance.OnSiteChat += Instance_OnSiteChat; Callbacks.Add("OnSiteChat", (Func <object, Task <object> >)input["OnSiteChat"]); Instance.OnSiteBetFinished += Instance_OnSiteDiceBetFinished; Callbacks.Add("OnSiteDiceBetFinished", (Func <object, Task <object> >)input["OnSiteDiceBetFinished"]); Instance.OnSiteError += Instance_OnSiteError; Callbacks.Add("OnSiteError", (Func <object, Task <object> >)input["OnSiteError"]); Instance.OnSiteLoginFinished += Instance_OnSiteLoginFinished; Callbacks.Add("OnSiteLoginFinished", (Func <object, Task <object> >)input["OnSiteLoginFinished"]); Instance.OnSiteNotify += Instance_OnSiteNotify; Callbacks.Add("OnSiteNotify", (Func <object, Task <object> >)input["OnSiteNotify"]); Instance.OnSiteRegisterFinished += Instance_OnSiteRegisterFinished; Callbacks.Add("OnSiteRegisterFinished", (Func <object, Task <object> >)input["OnSiteRegisterFinished"]); Instance.OnSiteStatsUpdated += Instance_OnSiteStatsUpdated; Callbacks.Add("OnSiteStatsUpdated", (Func <object, Task <object> >)input["OnSiteStatsUpdated"]); Instance.LoadPersonalSettings("personalsettings.json"); Instance.LoadBetSettings("betsettings.json"); Instance.CompileSites(); } //Instance.Sites = null; Logger.DumpLog("Finished creating instance, creating task and returning", 6); Task <object> taskA = new Task <object>(() => (Instance)); //taskA.Start(); taskA.RunSynchronously(); Logger.DumpLog("Finished creating instance, returning", 6); return(taskA); }
public void Start() { DiceBot = new Doormat(); DiceBot.OnSiteBetFinished += DiceBot_OnSiteDiceBetFinished; DiceBot.OnSiteAction += DiceBot_OnSiteAction; DiceBot.OnSiteChat += DiceBot_OnSiteChat; DiceBot.OnSiteError += DiceBot_OnSiteError; DiceBot.OnSiteLoginFinished += DiceBot_OnSiteLoginFinished; DiceBot.OnSiteNotify += DiceBot_OnSiteNotify; DiceBot.OnSiteRegisterFinished += DiceBot_OnSiteRegisterFinished; DiceBot.OnSiteStatsUpdated += DiceBot_OnSiteStatsUpdated; DiceBot.NeedConstringPassword += DiceBot_NeedConstringPassword; DiceBot.NeedKeepassPassword += DiceBot_NeedKeepassPassword; if (File.Exists("personalsettings.json")) { try { DiceBot.LoadPersonalSettings("personalsettings.json"); } catch (Exception e) { Logger.DumpLog(e); } } if (DiceBot.PersonalSettings != null) { if (string.IsNullOrWhiteSpace(DiceBot.PersonalSettings.EncrConnectionString)) { ConfigureDatabase(); } } if (File.Exists("betsettings.json")) { try { DiceBot.LoadBetSettings("betsettings.json"); } catch (Exception e) { Logger.DumpLog(e); } } SelectSite(); PrintCurrentActions(); string Input = Console.ReadLine(); while (Input.ToLower() != "exit") { try { switch (Input.ToLower()) { case "login": Login(); break; case "site": SelectSite(); break; case "currency": SelectCurrency(); break; case "logout": Logout(); break; case "sitestats": PrintSiteStats(); break; case "strategy": Strategy(); break; case "stats": Stats(); break; case "start": Console.Clear(); bets = new List <DiceBet>(); DiceBot.SavePersonalSettings("personalsettings.json"); DiceBot.SaveBetSettings("betsettings.json"); DiceBot.Start(); break; case "stop": DiceBot.StopStrategy("Stop received from console."); break; case "sim": Simulate(); break; case "betsettings": BetSettings(); break; case "personalsettings": PersonalSetting(); break; } } catch (Exception e) { Console.WriteLine(e.Message); } PrintCurrentActions(); if (DiceBot.Running) { this.Input = ""; char CharRead = Console.ReadKey().KeyChar; while (CharRead != '\n' && CharRead != '\r') { this.Input += CharRead; if ((CharRead != '\n' && CharRead != '\r')) { CharRead = Console.ReadKey().KeyChar; } } Input = this.Input; } else { Input = Console.ReadLine(); } } try { DiceBot.SavePersonalSettings("personalsettings.json"); DiceBot.SaveBetSettings("betsettings.json"); DiceBot.CurrentSite.Disconnect(); } catch (Exception e) { Logger.DumpLog(e); } }