private static void ConnectionThread() { try { DateTime dateTime_ = DateTime.Now; while (true) { TimeSpan ts = (DateTime.Now - Client.lastPacket); if (!Server.IsConnected() || ts.TotalSeconds > 70.0) { BotSession.Sessionreconnects++; break; } TimeSpan ts2 = (DateTime.Now - dateTime_); if (ts2.TotalMinutes >= 1.0) { GC.Collect(); GC.WaitForPendingFinalizers(); HelpTools.ClearMemory(HelpTools.GetCurrentProcess()); dateTime_ = DateTime.Now; } TimeSpan ts3 = (DateTime.Now - BotSession.dailyQuestFinishTime); if (ts3.TotalHours >= 24 && ts3.TotalMinutes >= 1 && ts3.TotalSeconds >= 1 && !BotSession.Sessioncandodailyquest) { BotSession.Sessioncandodailyquest = true; } Thread.Sleep(1000); } Thread.Sleep(2000); Bot.Running = false; if (Server._targetSocket != null && Server._targetSocket.Connected) { Server._targetSocket.Close(); } if (Bot.Running) { BotLogic.StopBotThread(); } if (BotLogic.OnAttackRunning) { BotLogic.StoponAttackThrad(); } Server.Connected = false; if (BotSettings.tasksDoneLogout && TaskSystem.TasksSystem.LogginOut) { return; } BotSession.lostConnection = true; } catch (Exception ex) { BotMethods.WriteLine("There was an error in the connection-Thread!\n\n" + ex.Message); ConnectionThread(); return; } }
public void LicenseThread() { var _restartCounter = 0; IL_BEGIN: try { while (true) { try { this.Authenticate(); var versionflag = CheckVersion(); if (!versionflag) { if (!Bot.Running && !BotLogic.OnAttackRunning && !BotSession.logginIn && !BotSession.loggedIn) { if (MessageBox.Show("A new version is available!\nDo you wish to visit the download-area now?", "New Version!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start("https://www.elitepvpers.com/forum/seafight/4222822-release-boxybot.html"); } } BotMethods.WriteLine("A newer Version is available!"); } if (status == "-4") { BotMethods.WriteLine("License Suspended!"); MessageBox.Show("Your License has been suspended!", "License suspended!"); Account.gClass = null; } else if (status == "-3") { BotMethods.WriteLine(string.Join("", new string[] { HelpTools.FromByteToString(32), HelpTools.FromByteToString(45), HelpTools.FromByteToString(32), HelpTools.FromByteToString(76), HelpTools.FromByteToString(105), HelpTools.FromByteToString(99), HelpTools.FromByteToString(101), HelpTools.FromByteToString(110), HelpTools.FromByteToString(115), HelpTools.FromByteToString(01), HelpTools.FromByteToString(32), HelpTools.FromByteToString(69), HelpTools.FromByteToString(120), HelpTools.FromByteToString(112), HelpTools.FromByteToString(105), HelpTools.FromByteToString(114), HelpTools.FromByteToString(101), HelpTools.FromByteToString(100), HelpTools.FromByteToString(33), })); try { if (Bot.Running) { BotLogic.StopBotThread(); } if (BotLogic.OnAttackRunning) { BotLogic.StoponAttackThrad(); } } catch (Exception ex) { BotMethods.WriteLine("Could not shutdown Bot-Threads!\n" + ex); } Bot.Running = false; BotLogic.OnAttackRunning = false; Account.gClass = null; if (MessageBox.Show("Your License has expired!\nDo you want to buy a new one?", "License Expired!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Form1.form1.ShowPaymentForm(); } Account.gClass = null; } else if (status == "-1") { BotMethods.WriteLine("There was an internal Server Error!\nPlease check your internet connection!\nRetrying in 3min!"); Account.gClass = null; } else if (status == "1") { if (Account.gClass == null) { Account.gClass = new UserInitMessage(); } } var ts = (validUntil - DateTime.Now); if (ts.TotalHours < 25.0) { if (HelpTools.IsVirtualMachine()) { try { BotCalculator.StopThreads(); if (Bot.Running) { BotLogic.StopBotThread(); } if (BotLogic.OnAttackRunning) { BotLogic.StoponAttackThrad(); } } catch (Exception) { } Bot.Running = false; BotLogic.OnAttackRunning = false; Account.gClass = null; if (MessageBox.Show("This program does not work on a Virtual Machine unless you own a Premium License!", "VM Detected!", MessageBoxButtons.OK, MessageBoxIcon.Error) != DialogResult.None) { Application.Exit(); Process.GetCurrentProcess().Kill(); } } } Thread.Sleep(180000); } catch (Exception ex) { BotMethods.WriteLine("There was an error while checking License!\nRetrying in a few seconds!\n" + ex.Message); Thread.Sleep(50000); } } } catch (Exception ex) { BotMethods.WriteLine("Restarting License-Thread, reason: " + ex.Message); _restartCounter++; if (_restartCounter > 14) { MessageBox.Show("There seems to be an error with the License-Thread!\nReason: " + ex + "\nPlease report this!\nThe Bot will now stop!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); Process.GetCurrentProcess().Kill(); } goto IL_BEGIN; } }