diff --git a/PokemonGo.RocketBot.Logic/DataDumper/Dumper.cs b/PokemonGo.RocketBot.Logic/DataDumper/Dumper.cs
index c23859b..1169d20 100644
--- a/PokemonGo.RocketBot.Logic/DataDumper/Dumper.cs
+++ b/PokemonGo.RocketBot.Logic/DataDumper/Dumper.cs
@@ -20,7 +20,7 @@ namespace PokemonGo.RocketBot.Logic.DataDumper
{
var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps");
var file = Path.Combine(path,
- $"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}");
+ $"RocketBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}");
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
// Clears all contents of a file first if overwrite is true
@@ -50,7 +50,7 @@ namespace PokemonGo.RocketBot.Logic.DataDumper
private static void DumpToFile(ISession session, string data, string filename, string extension = "csv")
{
var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps",
- $"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}");
+ $"RocketBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}");
using (
var dumpFile =
diff --git a/PokemonGo.RocketBot.Logic/Properties/AssemblyInfo.cs b/PokemonGo.RocketBot.Logic/Properties/AssemblyInfo.cs
index 33d79e5..f18cbf7 100644
--- a/PokemonGo.RocketBot.Logic/Properties/AssemblyInfo.cs
+++ b/PokemonGo.RocketBot.Logic/Properties/AssemblyInfo.cs
@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("NecroBot Logic for Pokémon GO")]
+[assembly: AssemblyTitle("RocketBot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
diff --git a/PokemonGo.RocketBot.Logic/State/VersionCheckState.cs b/PokemonGo.RocketBot.Logic/State/VersionCheckState.cs
index 2c30826..9d678c7 100644
--- a/PokemonGo.RocketBot.Logic/State/VersionCheckState.cs
+++ b/PokemonGo.RocketBot.Logic/State/VersionCheckState.cs
@@ -22,344 +22,11 @@ namespace PokemonGo.RocketBot.Logic.State
{
public class VersionCheckState : IState
{
- public const string VersionUri =
- "https://rawgit.com/NECROBOTIO/NecroBot/master/PokemonGo.RocketBot.Logic/Properties/AssemblyInfo.cs";
-
- public const string LatestReleaseApi =
- "https://api.github.com/repos/NECROBOTIO/NecroBot/releases/latest";
-
- private const string LatestRelease =
- "https://github.com/NECROBOTIO/NecroBot/releases";
-
- public static Version RemoteVersion;
-
+ // reserve for auto updater
public async Task<IState> Execute(ISession session, CancellationToken cancellationToken)
{
- cancellationToken.ThrowIfCancellationRequested();
-
- await CleanupOldFiles();
- var autoUpdate = session.LogicSettings.AutoUpdate;
- var isLatest = IsLatest();
- if ( isLatest || !autoUpdate )
- {
- if ( isLatest )
- {
- session.EventDispatcher.Send(new UpdateEvent
- {
- Message =
- session.Translation.GetTranslation(TranslationString.GotUpToDateVersion, Assembly.GetExecutingAssembly().GetName().Version.ToString(3))
- });
- return new LoginState();
- }
- session.EventDispatcher.Send(new UpdateEvent
- {
- Message = session.Translation.GetTranslation(TranslationString.AutoUpdaterDisabled, LatestRelease)
- });
-
- return new LoginState();
- } else
- {
- Logger.Write( "New update detected, would you like to update? Y/N", LogLevel.Update );
-
- bool boolBreak = false;
- while( !boolBreak )
- {
- string strInput = Console.ReadLine().ToLower();
-
- switch( strInput )
- {
- case "y":
- boolBreak = true;
- break;
- case "n":
- Logger.Write( "Update Skipped", LogLevel.Update );
- return new LoginState();
- default:
- Logger.Write( session.Translation.GetTranslation( TranslationString.PromptError, "Y", "N" ), LogLevel.Error );
- continue;
- }
- }
- }
-
- session.EventDispatcher.Send(new UpdateEvent
- {
- Message = session.Translation.GetTranslation(TranslationString.DownloadingUpdate)
- });
- var remoteReleaseUrl =
- $"https://github.com/NecronomiconCoding/NecroBot/releases/download/v{RemoteVersion}/";
- const string zipName = "Release.zip";
- var downloadLink = remoteReleaseUrl + zipName;
- var baseDir = Directory.GetCurrentDirectory();
- var downloadFilePath = Path.Combine(baseDir, zipName);
- var tempPath = Path.Combine(baseDir, "tmp");
- var extractedDir = Path.Combine(tempPath, "Release");
- var destinationDir = baseDir + Path.DirectorySeparatorChar;
- Console.WriteLine(downloadLink);
-
- if (!DownloadFile(downloadLink, downloadFilePath))
- return new LoginState();
-
- session.EventDispatcher.Send(new UpdateEvent
- {
- Message = session.Translation.GetTranslation(TranslationString.FinishedDownloadingRelease)
- });
-
- if (!UnpackFile(downloadFilePath, tempPath))
- return new LoginState();
-
- session.EventDispatcher.Send(new UpdateEvent
- {
- Message = session.Translation.GetTranslation(TranslationString.FinishedUnpackingFiles)
- });
-
- if (!MoveAllFiles(extractedDir, destinationDir))
- return new LoginState();
-
- session.EventDispatcher.Send(new UpdateEvent
- {
- Message = session.Translation.GetTranslation(TranslationString.UpdateFinished)
- });
-
- if( TransferConfig( baseDir, session ) )
- Utils.ErrorHandler.ThrowFatalError( session.Translation.GetTranslation( TranslationString.FinishedTransferringConfig ), 5, LogLevel.Update );
-
- Process.Start(Assembly.GetEntryAssembly().Location);
- Environment.Exit(-1);
- return null;
+ return new LoginState();
}
- public static async Task CleanupOldFiles()
- {
- var tmpDir = Path.Combine(Directory.GetCurrentDirectory(), "tmp");
-
- if (Directory.Exists(tmpDir))
- {
- Directory.Delete(tmpDir, true);
- }
-
- var di = new DirectoryInfo(Directory.GetCurrentDirectory());
- var files = di.GetFiles("*.old", SearchOption.AllDirectories);
-
- foreach (var file in files)
- {
- try
- {
- if (file.Name.Contains("vshost") || file.Name.Contains(".gpx.old"))
- continue;
- File.Delete(file.FullName);
- }
- catch (Exception e)
- {
- Logger.Write(e.ToString());
- }
- }
- await Task.Delay(200);
- }
-
- public static bool DownloadFile(string url, string dest)
- {
- using (var client = new WebClient())
- {
- try
- {
- client.DownloadFile(url, dest);
- Console.WriteLine(dest);
- }
- catch
- {
- // ignored
- }
- return true;
- }
- }
-
- private static string DownloadServerVersion()
- {
- using (var wC = new NecroWebClient())
- {
- return wC.DownloadString(VersionUri);
- }
- }
-
- private static JObject GetJObject(string filePath)
- {
- return JObject.Parse(File.ReadAllText(filePath));
- }
-
-
- public static bool IsLatest()
- {
- try
- {
- var regex = new Regex(@"\[assembly\: AssemblyVersion\(""(\d{1,})\.(\d{1,})\.(\d{1,})""\)\]");
- var match = regex.Match(DownloadServerVersion());
-
- if (!match.Success)
- return false;
-
- var gitVersion = new Version($"{match.Groups[1]}.{match.Groups[2]}.{match.Groups[3]}");
- RemoteVersion = gitVersion;
- if (gitVersion >= Assembly.GetExecutingAssembly().GetName().Version)
- return false;
- }
- catch (Exception)
- {
- return true; //better than just doing nothing when git server down
- }
-
- return true;
- }
-
- public static bool MoveAllFiles(string sourceFolder, string destFolder)
- {
- if (!Directory.Exists(destFolder))
- Directory.CreateDirectory(destFolder);
-
- var oldfiles = Directory.GetFiles(destFolder);
- foreach (var old in oldfiles)
- {
- if (old.Contains("vshost") || old.Contains(".gpx")) continue;
- File.Move(old, old + ".old");
- }
-
- try
- {
- var files = Directory.GetFiles(sourceFolder);
- foreach (var file in files)
- {
- if (file.Contains("vshost") || file.Contains(".gpx")) continue;
- var name = Path.GetFileName(file);
- var dest = Path.Combine(destFolder, name);
- File.Copy(file, dest, true);
- }
-
- var folders = Directory.GetDirectories(sourceFolder);
-
- foreach (var folder in folders)
- {
- var name = Path.GetFileName(folder);
- if (name == null) continue;
- var dest = Path.Combine(destFolder, name);
- MoveAllFiles(folder, dest);
- }
- }
- catch (Exception)
- {
- return false;
- }
- return true;
- }
-
- private static bool TransferConfig(string baseDir, ISession session)
- {
- if (!session.LogicSettings.TransferConfigAndAuthOnUpdate)
- return false;
-
- var configDir = Path.Combine(baseDir, "Config");
- if (!Directory.Exists(configDir))
- return false;
-
- var oldConf = GetJObject(Path.Combine(configDir, "config.json.old"));
- var oldAuth = GetJObject(Path.Combine(configDir, "auth.json.old"));
- GlobalSettings.Load("");
-
- var newConf = GetJObject(Path.Combine(configDir, "config.json"));
- var newAuth = GetJObject(Path.Combine(configDir, "auth.json"));
-
- List<JProperty> lstNewOptions = TransferJson(oldConf, newConf);
- TransferJson(oldAuth, newAuth);
-
- File.WriteAllText(Path.Combine(configDir, "config.json"), newConf.ToString());
- File.WriteAllText(Path.Combine(configDir, "auth.json"), newAuth.ToString());
-
- if( lstNewOptions != null && lstNewOptions.Count > 0 )
- {
- Console.Write( "\n" );
- Logger.Write( "### New Options found ###", LogLevel.New );
-
- foreach( JProperty prop in lstNewOptions )
- Logger.Write( prop.ToString(), LogLevel.New );
-
- Logger.Write( "Would you like to open the Config file? Y/N", LogLevel.Info );
-
- while( true )
- {
- string strInput = Console.ReadLine().ToLower();
-
- switch( strInput )
- {
- case "y":
- Process.Start( Path.Combine( configDir, "config.json" ) );
- return true;
- case "n":
- Utils.ErrorHandler.ThrowFatalError( session.Translation.GetTranslation( TranslationString.FinishedTransferringConfig ), 5, LogLevel.Update, true );
- return true;
- default:
- Logger.Write( session.Translation.GetTranslation( TranslationString.PromptError, "y", "n" ), LogLevel.Error );
- continue;
- }
- }
- }
-
- return true;
- }
-
- private static List<JProperty> TransferJson(JObject oldFile, JObject newFile)
- {
- try
- {
- // Figuring out the best method to detect new settings \\
- List<JProperty> lstNewOptions = new List<JProperty>();
-
- foreach( var newProperty in newFile.Properties() )
- {
- bool boolFound = false;
-
- foreach( var oldProperty in oldFile.Properties() )
- {
- if( newProperty.Name.Equals( oldProperty.Name ) )
- {
- boolFound = true;
- newFile[ newProperty.Name ] = oldProperty.Value;
- break;
- }
- }
-
- if( !boolFound )
- lstNewOptions.Add( newProperty );
- }
-
- return lstNewOptions;
-
- /*foreach (var newProperty in newFile.Properties())
- foreach (var oldProperty in oldFile.Properties())
- if (newProperty.Name.Equals(oldProperty.Name))
- {
- newFile[newProperty.Name] = oldProperty.Value;
- break;
- }*/
- }
- catch( Exception error )
- {
- Console.WriteLine( error.Message );
- }
-
- return null;
- }
-
- public static bool UnpackFile(string sourceTarget, string destPath)
- {
- var source = sourceTarget;
- var dest = destPath;
- try
- {
- ZipFile.ExtractToDirectory(source, dest);
- }
- catch (Exception)
- {
- return false;
- }
- return true;
- }
}
}
\ No newline at end of file
diff --git a/PokemonGo.RocketBot.Window/MainForm.cs b/PokemonGo.RocketBot.Window/MainForm.cs
index 119eb1f..9b48fd4 100644
--- a/PokemonGo.RocketBot.Window/MainForm.cs
+++ b/PokemonGo.RocketBot.Window/MainForm.cs
@@ -11,7 +11,6 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using BrightIdeasSoftware;
-using PokemonGo.RocketAPI.Exceptions;
using PokemonGo.RocketAPI.Helpers;
using PokemonGo.RocketBot.Logic;
using PokemonGo.RocketBot.Logic.Common;
@@ -86,10 +85,10 @@ namespace PokemonGo.RocketBot.Window
if (File.Exists(configFile))
{
- if (!VersionCheckState.IsLatest())
+ /** if (!VersionCheckState.IsLatest())
settings = GlobalSettings.Load(subPath, true);
- else
- settings = GlobalSettings.Load(subPath);
+ else **/
+ settings = GlobalSettings.Load(subPath);
}
else
{
@@ -108,7 +107,7 @@ namespace PokemonGo.RocketBot.Window
if (boolNeedsSetup)
{
menuStrip1.ShowItemToolTips = true;
- startStopBotToolStripMenuItem.ToolTipText = "Please goto settings and enter your basic info";
+ startStopBotToolStripMenuItem.ToolTipText = @"Please goto settings and enter your basic info";
return;
/** if (GlobalSettings.PromptForSetup(session.Translation) && !settings.isGui)
{
@@ -169,6 +168,7 @@ namespace PokemonGo.RocketBot.Window
session.Navigation.UpdatePositionEvent +=
(lat, lng) => session.EventDispatcher.Send(new UpdatePositionEvent { Latitude = lat, Longitude = lng });
session.Navigation.UpdatePositionEvent += Navigation_UpdatePositionEvent;
+
machine.AsyncStart(new VersionCheckState(), session);
if (settings.UseTelegramAPI)
@@ -199,21 +199,6 @@ namespace PokemonGo.RocketBot.Window
throw new Exception();
}
- public static void ColoredConsoleWrite(Color color, string text)
- {
- if (text.Length <= 0)
- return;
- var message = text;
- if (Instance.InvokeRequired)
- {
- Instance.Invoke(new Action<Color, string>(ColoredConsoleWrite), color, message);
- return;
- }
- Instance.logTextBox.Select(Instance.logTextBox.Text.Length, 1); // Reset cursor to last
- Instance.logTextBox.SelectionColor = color;
- Instance.logTextBox.AppendText(message);
- }
-
private static bool BoolNeedsSetup()
{
var profilePath = Path.Combine(Directory.GetCurrentDirectory(), subPath);
@@ -259,6 +244,33 @@ namespace PokemonGo.RocketBot.Window
"https://raw.githubusercontent.com/TheUnnameOrganization/RocketBot/Beta-Build/src/RocketBotGUI/Properties/AssemblyInfo.cs");
}
+ #region INTERFACE
+ public static void ColoredConsoleWrite(Color color, string text)
+ {
+ if (text.Length <= 0)
+ return;
+ var message = text;
+ if (Instance.InvokeRequired)
+ {
+ Instance.Invoke(new Action<Color, string>(ColoredConsoleWrite), color, message);
+ return;
+ }
+ Instance.logTextBox.Select(Instance.logTextBox.Text.Length, 1); // Reset cursor to last
+ Instance.logTextBox.SelectionColor = color;
+ Instance.logTextBox.AppendText(message);
+ }
+
+ public static void SetStatusText(string text)
+ {
+ if (Instance.InvokeRequired)
+ {
+ Instance.Invoke(new Action<string>(SetStatusText), text);
+ return;
+ }
+ Instance.statusLabel.Text = text;
+ }
+ #endregion INTERFACE
+
#region BUTTONS
private void btnRefresh_Click(object sender, EventArgs e)
{
You may download the files in Public Git.