public BotInstance(Data.APIIntergrations.RewardCurrencyAPI.Objects.Currency Currency) { this.Currency = Currency; this.CommandConfig = this.Currency.CommandConfig; this.LoginConfig = this.Currency.LoginConfig; //new Thread(() => CheckBotsAlive()).Start(); Start(); }
public static void Start() { string S = Data.APIIntergrations.RewardCurrencyAPI.WebRequests.GetAuthToken(); if (S == null) { Console.WriteLine("API Tokens misconfigured!"); } else { while (true) { foreach (Newtonsoft.Json.Linq.JToken Currency in Data.APIIntergrations.RewardCurrencyAPI.WebRequests.PostRequest("currency/all", null, true).Data) { Data.APIIntergrations.RewardCurrencyAPI.Objects.Currency C = Data.APIIntergrations.RewardCurrencyAPI.Objects.Currency.FromJson(Currency); if (C.CommandConfig.Count() != 0 && C.LoginConfig.Count() != 0) { if (C.CommandConfig["BotsEnabled"].ToString() == "True") { if (!Instances.Keys.Contains(C.ID)) { Instances.Add(C.ID, new BotInstance(C)); } else { Instances[C.ID].CommandConfig = C.CommandConfig; Instances[C.ID].LoginConfig = C.LoginConfig; Instances[C.ID].Currency = C; Instances[C.ID].Start(); } } else if (Instances.Keys.Contains(C.ID)) { Instances[C.ID].Stop(); } } else { Console.WriteLine("There was a error relating to currency configs"); } } System.Threading.Thread.Sleep(300000); } } }