From 3a86cc66474158efdfa7f302c4ffd9c0e19958b2 Mon Sep 17 00:00:00 2001 From: trailTrial Date: Sun, 31 Jul 2016 17:09:55 -0700 Subject: [PATCH 01/10] #138 add PlayerDelay to Evolve task --- PoGo.PokeMobBot.Logic/Tasks/EvolvePokemonTask.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PoGo.PokeMobBot.Logic/Tasks/EvolvePokemonTask.cs b/PoGo.PokeMobBot.Logic/Tasks/EvolvePokemonTask.cs index 182888d..331859c 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/EvolvePokemonTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/EvolvePokemonTask.cs @@ -63,6 +63,8 @@ public static async Task Execute(ISession session, CancellationToken cancellatio Exp = evolveResponse.ExperienceAwarded, Result = evolveResponse.Result }); + + await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 0); } } } From e7087d3769d0fae37588a8dba4591b6fd3c9a84c Mon Sep 17 00:00:00 2001 From: PocketMobsters Date: Sun, 31 Jul 2016 20:57:50 -0500 Subject: [PATCH 02/10] Fix duplicate recycle message --- .../Tasks/RecycleItemsTask.cs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs index 447cf9f..fdc07b1 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs @@ -260,28 +260,6 @@ private static async Task OptimizedRecycleRevives(ISession session, Cancellation await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500); } } - - if (diff > 0) - { - int maxRevivesToKeep = maxReviveCount - diff; - if (maxRevivesToKeep < 0) - { - maxRevivesToKeep = 0; - } - maxRevivesToRecycle = maxReviveCount - maxRevivesToKeep; - - if (maxRevivesToRecycle != 0) - { - diff -= maxRevivesToRecycle; - cancellationToken.ThrowIfCancellationRequested(); - await session.Client.Inventory.RecycleItem(ItemId.ItemMaxRevive, maxRevivesToRecycle); - session.EventDispatcher.Send(new ItemRecycledEvent { Id = ItemId.ItemMaxRevive, Count = maxRevivesToRecycle }); - if (session.LogicSettings.Teleport) - await Task.Delay(session.LogicSettings.DelayRecyleItem); - else - await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500); - } - } } } } From 3260ae6acb48de606bd940ab5e7854d39afe56f1 Mon Sep 17 00:00:00 2001 From: PocketMobsters Date: Sun, 31 Jul 2016 21:01:11 -0500 Subject: [PATCH 03/10] Fixed CSV export lock --- PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs b/PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs index ece5502..728c62d 100644 --- a/PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs +++ b/PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs @@ -21,7 +21,7 @@ public static void ClearDumpFile(ISession session, string filename, string exten { var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps"); var file = Path.Combine(path, - $"PokeMobBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}"); + $"PokeMobBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH:mm:ss")}.{extension}"); if (!Directory.Exists(path)) Directory.CreateDirectory(path); // Clears all contents of a file first if overwrite is true @@ -52,7 +52,7 @@ public static void Dump(ISession session, string data, string filename, string e private static void DumpToFile(ISession session, string data, string filename, string extension = "txt") { var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps", - $"PokeMobBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}"); + $"PokeMobBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH:mm:ss")}.{extension}"); using ( var dumpFile = From ade0d4cb817619904dada19ae80fa56be71503b8 Mon Sep 17 00:00:00 2001 From: PocketMobsters Date: Sun, 31 Jul 2016 21:09:43 -0500 Subject: [PATCH 04/10] Removed CSV export functionality for now. --- .../Tasks/DisplayPokemonStatsTask.cs | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/PoGo.PokeMobBot.Logic/Tasks/DisplayPokemonStatsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/DisplayPokemonStatsTask.cs index eca760a..57fee78 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/DisplayPokemonStatsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/DisplayPokemonStatsTask.cs @@ -75,22 +75,23 @@ public static async Task Execute(ISession session) var allPokemonInBag = session.LogicSettings.PrioritizeIvOverCp ? await session.Inventory.GetHighestsPerfect(1000) : await session.Inventory.GetHighestsCp(1000); - if (session.LogicSettings.DumpPokemonStats) - { - const string dumpFileName = "PokeBagStats"; - Dumper.ClearDumpFile(session, dumpFileName); - Dumper.ClearDumpFile(session, dumpFileName, "csv"); - Dumper.Dump(session, "Name,Level,CP,IV,Move1,Move2", dumpFileName, "csv"); - foreach (var pokemon in allPokemonInBag) - { - Dumper.Dump(session, - $"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: {PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: {pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: {pokemon.Move1}\t\t\tMOVE2: {pokemon.Move2}", - dumpFileName); - Dumper.Dump(session, - $"{pokemon.PokemonId},{PokemonInfo.GetLevel(pokemon).ToString("00")},{pokemon.Cp},{PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%,{pokemon.Move1},{pokemon.Move2}", - dumpFileName, "csv"); - } - } + //if (session.LogicSettings.DumpPokemonStats) + //{ + // const string dumpFileName = "PokeBagStats"; + // Dumper.ClearDumpFile(session, dumpFileName); + + // Dumper.ClearDumpFile(session, dumpFileName, "csv"); + // Dumper.Dump(session, "Name,Level,CP,IV,Move1,Move2", dumpFileName, "csv"); + // foreach (var pokemon in allPokemonInBag) + // { + // Dumper.Dump(session, + // $"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: {PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: {pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: {pokemon.Move1}\t\t\tMOVE2: {pokemon.Move2}", + // dumpFileName); + // Dumper.Dump(session, + // $"{pokemon.PokemonId},{PokemonInfo.GetLevel(pokemon).ToString("00")},{pokemon.Cp},{PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%,{pokemon.Move1},{pokemon.Move2}", + // dumpFileName, "csv"); + // } + //} if(session.LogicSettings.Teleport) await Task.Delay(session.LogicSettings.DelayDisplayPokemon); else From dafdc68e5a8009cb6c0819813fb19e15494e53e9 Mon Sep 17 00:00:00 2001 From: PocketMobsters Date: Sun, 31 Jul 2016 21:11:03 -0500 Subject: [PATCH 05/10] Revert "Removed CSV export functionality for now." This reverts commit ade0d4cb817619904dada19ae80fa56be71503b8. --- .../Tasks/DisplayPokemonStatsTask.cs | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/PoGo.PokeMobBot.Logic/Tasks/DisplayPokemonStatsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/DisplayPokemonStatsTask.cs index 57fee78..eca760a 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/DisplayPokemonStatsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/DisplayPokemonStatsTask.cs @@ -75,23 +75,22 @@ public static async Task Execute(ISession session) var allPokemonInBag = session.LogicSettings.PrioritizeIvOverCp ? await session.Inventory.GetHighestsPerfect(1000) : await session.Inventory.GetHighestsCp(1000); - //if (session.LogicSettings.DumpPokemonStats) - //{ - // const string dumpFileName = "PokeBagStats"; - // Dumper.ClearDumpFile(session, dumpFileName); - - // Dumper.ClearDumpFile(session, dumpFileName, "csv"); - // Dumper.Dump(session, "Name,Level,CP,IV,Move1,Move2", dumpFileName, "csv"); - // foreach (var pokemon in allPokemonInBag) - // { - // Dumper.Dump(session, - // $"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: {PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: {pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: {pokemon.Move1}\t\t\tMOVE2: {pokemon.Move2}", - // dumpFileName); - // Dumper.Dump(session, - // $"{pokemon.PokemonId},{PokemonInfo.GetLevel(pokemon).ToString("00")},{pokemon.Cp},{PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%,{pokemon.Move1},{pokemon.Move2}", - // dumpFileName, "csv"); - // } - //} + if (session.LogicSettings.DumpPokemonStats) + { + const string dumpFileName = "PokeBagStats"; + Dumper.ClearDumpFile(session, dumpFileName); + Dumper.ClearDumpFile(session, dumpFileName, "csv"); + Dumper.Dump(session, "Name,Level,CP,IV,Move1,Move2", dumpFileName, "csv"); + foreach (var pokemon in allPokemonInBag) + { + Dumper.Dump(session, + $"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: {PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: {pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: {pokemon.Move1}\t\t\tMOVE2: {pokemon.Move2}", + dumpFileName); + Dumper.Dump(session, + $"{pokemon.PokemonId},{PokemonInfo.GetLevel(pokemon).ToString("00")},{pokemon.Cp},{PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%,{pokemon.Move1},{pokemon.Move2}", + dumpFileName, "csv"); + } + } if(session.LogicSettings.Teleport) await Task.Delay(session.LogicSettings.DelayDisplayPokemon); else From f02109bba66b3c76a29f595c93cf369aa7a68f51 Mon Sep 17 00:00:00 2001 From: Xores Date: Mon, 1 Aug 2016 10:14:27 +0200 Subject: [PATCH 06/10] Update translation.de.json corrected RazzBerry Name and added German Line for Not enough Pokemon for lucky egg. --- PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json b/PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json index 9d58ddf..d99266e 100644 --- a/PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json +++ b/PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json @@ -83,7 +83,7 @@ }, { "Key": "eventUseLuckyEggMinPokemonCheck", - "Value": "Not enough Pokemon to trigger a lucky egg. Waiting for {0} more. ({1}/{2})" + "Value": "Nicht genug Pokemon vorhanden um Glücks-Ei zu benutzen. Warte auf {0} mehr. ({1}/{2})" }, { "Key": "eventPokemonEvolvedSuccess", @@ -325,7 +325,7 @@ }, { "Key": "UseBerry", - "Value": "Benutze Himbeere. Verbleibend: {0}" + "Value": "Benutze Himmihbeere. Verbleibend: {0}" } ] } From 574f973cbdad371378fbe87d4b3151c47b00968b Mon Sep 17 00:00:00 2001 From: Eric Lindsey Date: Mon, 1 Aug 2016 08:50:29 -0400 Subject: [PATCH 07/10] Add support for bi-directional support with PogoLocationFeeder for encounters --- .../Tasks/CatchLurePokemonsTask.cs | 19 ++++++++++++ .../Tasks/CatchNearbyPokemonsTask.cs | 17 +++++++++++ .../Tasks/SnipePokemonTask.cs | 29 +++++++++++++++++-- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs index e6f341d..c6a5915 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs @@ -1,10 +1,13 @@ #region using directives +using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using PoGo.PokeMobBot.Logic.Common; using PoGo.PokeMobBot.Logic.Event; using PoGo.PokeMobBot.Logic.Logging; +using PoGo.PokeMobBot.Logic.PoGoUtils; using PoGo.PokeMobBot.Logic.State; using POGOProtos.Map.Fort; using POGOProtos.Networking.Responses; @@ -15,6 +18,8 @@ namespace PoGo.PokeMobBot.Logic.Tasks { public static class CatchLurePokemonsTask { + private static HashSet cache; + public static async Task Execute(ISession session, FortData currentFortData, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -38,6 +43,20 @@ public static async Task Execute(ISession session, FortData currentFortData, Can var encounterId = currentFortData.LureInfo.EncounterId; var encounter = await session.Client.Encounter.EncounterLurePokemon(encounterId, fortId); + // Feed this encounter back to the snipe server + if (session.LogicSettings.UseSnipeLocationServer) + { + var payload = new SniperInfo + { + TimeStamp = DateTime.Now, + Latitude = currentFortData.Latitude, + Longitude = currentFortData.Longitude, + Iv = PokemonInfo.CalculatePokemonPerfection(encounter.PokemonData), + Id = encounter.PokemonData.PokemonId, + }; + SnipePokemonTask.Feedback(payload); + } + if (encounter.Result == DiskEncounterResponse.Types.Result.Success) { await CatchPokemonTask.Execute(session, encounter, null, currentFortData, encounterId); diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs index 68d7292..b0a2c86 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs @@ -1,11 +1,14 @@ #region using directives +using System; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Newtonsoft.Json; using PoGo.PokeMobBot.Logic.Common; using PoGo.PokeMobBot.Logic.Event; using PoGo.PokeMobBot.Logic.Logging; +using PoGo.PokeMobBot.Logic.PoGoUtils; using PoGo.PokeMobBot.Logic.State; using PoGo.PokeMobBot.Logic.Utils; using POGOProtos.Inventory.Item; @@ -54,6 +57,20 @@ public static async Task Execute(ISession session, CancellationToken cancellatio var encounter = await session.Client.Encounter.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnPointId); + // Feed this encounter back to the snipe server + if (session.LogicSettings.UseSnipeLocationServer) + { + var payload = new SniperInfo + { + TimeStamp = DateTime.Now, + Latitude = encounter.WildPokemon.Latitude, + Longitude = encounter.WildPokemon.Longitude, + Iv = PokemonInfo.CalculatePokemonPerfection(encounter.WildPokemon.PokemonData), + Id = encounter.WildPokemon.PokemonData.PokemonId, + }; + SnipePokemonTask.Feedback(payload); + } + if (encounter.Status == EncounterResponse.Types.Status.EncounterSuccess) { await CatchPokemonTask.Execute(session, encounter, pokemon); diff --git a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs index af6a315..ebc61ab 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs @@ -12,6 +12,7 @@ using Newtonsoft.Json; using PoGo.PokeMobBot.Logic.Common; using PoGo.PokeMobBot.Logic.Event; +using PoGo.PokeMobBot.Logic.Logging; using PoGo.PokeMobBot.Logic.State; using POGOProtos.Enums; using POGOProtos.Inventory.Item; @@ -335,6 +336,9 @@ private static ScanResult SnipeScanForPokemon(Location location) return scanResult; } + private static StreamReader Reader; + private static StreamWriter Writer; + public static async Task Start(Session session, CancellationToken cancellationToken) { while (true) @@ -346,11 +350,13 @@ public static async Task Start(Session session, CancellationToken cancellationTo lClient.Connect(session.LogicSettings.SnipeLocationServer, session.LogicSettings.SnipeLocationServerPort); - var sr = new StreamReader(lClient.GetStream()); + NetworkStream stream = lClient.GetStream(); + Reader = new StreamReader(stream); + Writer = new StreamWriter(stream); while (lClient.Connected) { - var line = sr.ReadLine(); + var line = Reader.ReadLine(); if (line == null) throw new Exception("Unable to ReadLine from sniper socket"); @@ -365,6 +371,12 @@ public static async Task Start(Session session, CancellationToken cancellationTo SnipeLocations.RemoveAll(x => DateTime.Now > x.TimeStampAdded.AddMinutes(15)); SnipeLocations.Add(info); } + + Reader.Close(); + Writer.Close(); + stream.Close(); + Reader = null; + Writer = null; } catch (SocketException) { @@ -381,5 +393,18 @@ public static async Task Start(Session session, CancellationToken cancellationTo await Task.Delay(5000, cancellationToken); } } + + /// + /// Sends a communication back to the feeder server. + /// + /// Message to send. + public static void Feedback(SniperInfo info) + { + if (Writer == null) + return; + Logger.Write($"Sending info to feeder: {info.Latitude:0.00000000},{info.Longitude:0.00000000} {info.Iv:0.00}% IV {info.Id}"); + Writer.WriteLine(JsonConvert.SerializeObject(info)); + Writer.Flush(); + } } } \ No newline at end of file From 0b30091098cc927291b3f4c5f8132e4283bb0eab Mon Sep 17 00:00:00 2001 From: Eric Lindsey Date: Mon, 1 Aug 2016 09:06:22 -0400 Subject: [PATCH 08/10] Forgot some changes --- .../Tasks/SnipePokemonTask.cs | 59 ++++++++++--------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs index 84e88e2..b26e78a 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs @@ -89,6 +89,8 @@ public static class SnipePokemonTask public static List LocsVisited = new List(); private static readonly List SnipeLocations = new List(); private static DateTime _lastSnipe = DateTime.MinValue; + private static StreamReader Reader; + private static StreamWriter Writer; public static Task AsyncStart(Session session, CancellationToken cancellationToken = default(CancellationToken)) { @@ -457,7 +459,7 @@ public static async Task Start(Session session, CancellationToken cancellationTo var currentTimestamp = t.TotalMilliseconds; var pokemonIds = session.LogicSettings.PokemonToSnipe.Pokemon; - var formatter = new NumberFormatInfo { NumberDecimalSeparator = "." }; + var formatter = new NumberFormatInfo {NumberDecimalSeparator = "."}; var offset = session.LogicSettings.SnipingScanOffset; // 0.003 = half a mile; maximum 0.06 is 10 miles @@ -502,7 +504,7 @@ public static async Task Start(Session session, CancellationToken cancellationTo catch (Exception ex) { // most likely System.IO.IOException - session.EventDispatcher.Send(new ErrorEvent { Message = ex.ToString() }); + session.EventDispatcher.Send(new ErrorEvent {Message = ex.ToString()}); scanResult = new ScanResult { Status = "fail", @@ -520,15 +522,15 @@ public static async Task Start(Session session, CancellationToken cancellationTo lClient.Connect(session.LogicSettings.SnipeLocationServer, session.LogicSettings.SnipeLocationServerPort); - NetworkStream stream = lClient.GetStream(); - Reader = new StreamReader(stream); - Writer = new StreamWriter(stream); + NetworkStream stream = lClient.GetStream(); + Reader = new StreamReader(stream); + Writer = new StreamWriter(stream); - while (lClient.Connected) - { - var line = Reader.ReadLine(); - if (line == null) - throw new Exception("Unable to ReadLine from sniper socket"); + while (lClient.Connected) + { + var line = Reader.ReadLine(); + if (line == null) + throw new Exception("Unable to ReadLine from sniper socket"); var info = JsonConvert.DeserializeObject(line); @@ -538,26 +540,27 @@ public static async Task Start(Session session, CancellationToken cancellationTo // we might have different precisions from other sources continue; - SnipeLocations.RemoveAll(x => DateTime.Now > x.TimeStampAdded.AddMinutes(15)); - SnipeLocations.Add(info); - } + SnipeLocations.RemoveAll(x => DateTime.Now > x.TimeStampAdded.AddMinutes(15)); + SnipeLocations.Add(info); + } - Reader.Close(); - Writer.Close(); - stream.Close(); - Reader = null; - Writer = null; - } - catch (SocketException) - { - // this is spammed to often. Maybe add it to debug log later - } - catch (Exception ex) - { - // most likely System.IO.IOException - session.EventDispatcher.Send(new ErrorEvent {Message = ex.ToString()}); + Reader.Close(); + Writer.Close(); + stream.Close(); + Reader = null; + Writer = null; + } + catch (SocketException) + { + // this is spammed to often. Maybe add it to debug log later + } + catch (Exception ex) + { + // most likely System.IO.IOException + session.EventDispatcher.Send(new ErrorEvent {Message = ex.ToString()}); + } + await Task.Delay(5000, cancellationToken); } - await Task.Delay(5000, cancellationToken); } } From 6200c99e61054c1664e8ab4b9f6cf8ef7304a63b Mon Sep 17 00:00:00 2001 From: Eric Lindsey Date: Mon, 1 Aug 2016 14:17:46 -0400 Subject: [PATCH 09/10] Support for Pokemon moves --- PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs | 3 ++- PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs | 3 ++- PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs index c6a5915..401b2d4 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs @@ -48,11 +48,12 @@ public static async Task Execute(ISession session, FortData currentFortData, Can { var payload = new SniperInfo { - TimeStamp = DateTime.Now, Latitude = currentFortData.Latitude, Longitude = currentFortData.Longitude, Iv = PokemonInfo.CalculatePokemonPerfection(encounter.PokemonData), Id = encounter.PokemonData.PokemonId, + Move1 = encounter.PokemonData.Move1, + Move2 = encounter.PokemonData.Move2, }; SnipePokemonTask.Feedback(payload); } diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs index b0a2c86..db30ef0 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs @@ -62,11 +62,12 @@ public static async Task Execute(ISession session, CancellationToken cancellatio { var payload = new SniperInfo { - TimeStamp = DateTime.Now, Latitude = encounter.WildPokemon.Latitude, Longitude = encounter.WildPokemon.Longitude, Iv = PokemonInfo.CalculatePokemonPerfection(encounter.WildPokemon.PokemonData), Id = encounter.WildPokemon.PokemonData.PokemonId, + Move1 = encounter.WildPokemon.PokemonData.Move1, + Move2 = encounter.WildPokemon.PokemonData.Move2, }; SnipePokemonTask.Feedback(payload); } diff --git a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs index b26e78a..1e82bd1 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs @@ -31,6 +31,8 @@ public class SniperInfo public double Iv { get; set; } public DateTime TimeStamp { get; set; } public PokemonId Id { get; set; } + public PokemonMove Move1 { get; set; } + public PokemonMove Move2 { get; set; } [JsonIgnore] public DateTime TimeStampAdded { get; set; } = DateTime.Now; @@ -572,7 +574,7 @@ public static void Feedback(SniperInfo info) { if (Writer == null) return; - Logger.Write($"Sending info to feeder: {info.Latitude:0.00000000},{info.Longitude:0.00000000} {info.Iv:0.00}% IV {info.Id}"); + Logger.Write($"Sending info to feeder: {info.Latitude:0.00000000},{info.Longitude:0.00000000} {info.Iv:0.00}% IV {info.Id} {info.Move1} {info.Move2}"); Writer.WriteLine(JsonConvert.SerializeObject(info)); Writer.Flush(); } From 2761754581f9446333849742383d43e94c80fbde Mon Sep 17 00:00:00 2001 From: Eric Lindsey Date: Mon, 1 Aug 2016 16:47:27 -0400 Subject: [PATCH 10/10] Remove logging for Sending to feeder --- PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs index b8d236a..5b34603 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs @@ -691,7 +691,6 @@ public static void Feedback(SniperInfo info) { if (Writer == null) return; - Logger.Write($"Sending info to feeder: {info.Latitude:0.00000000},{info.Longitude:0.00000000} {info.Iv:0.00}% IV {info.Id} {info.Move1} {info.Move2}"); Writer.WriteLine(JsonConvert.SerializeObject(info)); Writer.Flush(); }