From cb07a50d0cafcf7cbacf12e769714b4b55d9a3bc Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sat, 27 Aug 2016 22:48:11 +0200 Subject: [PATCH 1/9] Add auto team in config template --- config.properties.template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.properties.template b/config.properties.template index c0548d923..fc0a8ed65 100644 --- a/config.properties.template +++ b/config.properties.template @@ -249,6 +249,8 @@ bot_timeout_after_catching_pokemon=-1 # Set if you want the bot to stop after visiting certain amount of pokestops, -1 skips it bot_timeout_after_visiting_pokestops=-1 +# Auto join team at level 5 or more. Can be NEUTRAL, RED, BLUE or YELLOW +auto_team=NEUTRAL # List of pokemon names #MISSINGNO From c95ef015e178d1aee7602eb3a55bb744fca356aa Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sat, 27 Aug 2016 22:48:45 +0200 Subject: [PATCH 2/9] Add auto team in json template --- json-template.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/json-template.json b/json-template.json index 426693d98..3f26dc756 100644 --- a/json-template.json +++ b/json-template.json @@ -83,6 +83,7 @@ "waitTimeMax" : 0, "botTimeoutAfterMinutes" : -1, "botTimeoutAfterCatchingPokemon" : -1, - "botTimeoutAfterVisitingPokestops" : -1 + "botTimeoutAfterVisitingPokestops" : -1, + "autoTeam" : "NEUTRAL" } From 44acd53972d88acb0d2c5ee0e22bd416d914a81c Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sat, 27 Aug 2016 22:51:34 +0200 Subject: [PATCH 3/9] Auto team added --- src/main/kotlin/ink/abb/pogo/scraper/Settings.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt index 65227150b..00a3c296c 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt @@ -151,6 +151,8 @@ class SettingsParser(val properties: Properties) { botTimeoutAfterMinutes = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_minutes", defaults.botTimeoutAfterMinutes, String::toInt), botTimeoutAfterCatchingPokemon = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_catching_pokemon", defaults.botTimeoutAfterCatchingPokemon, String::toInt), botTimeoutAfterVisitingPokestops = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_visiting_pokestops", defaults.botTimeoutAfterVisitingPokestops, String::toInt) + + autoTeam = getPropertyIfSet("Auto team", "auto_team", defaults.autoTeam, String::toString) ) } @@ -299,6 +301,8 @@ data class Settings( val botTimeoutAfterMinutes: Int = -1, val botTimeoutAfterCatchingPokemon:Int = -1, val botTimeoutAfterVisitingPokestops:Int = -1 + + val autoTeam: String = "NEUTRAL" ) { fun withName(name: String): Settings { this.name = name From 3b3fedb44f5cc811643784177497892fa458262d Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sat, 27 Aug 2016 22:52:34 +0200 Subject: [PATCH 4/9] Auto team added --- .../abb/pogo/scraper/tasks/UpdateProfile.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt index eb6125194..17e6053c8 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt @@ -111,5 +111,26 @@ class UpdateProfile : Task { } catch (e: Exception) { Log.red("Failed to update profile and inventories") } + if(ctx.api.playerProfile.playerData.team==TeamColor.NEUTRAL && ctx.api.playerProfile.stats.level>=5) { + if(settings.autoTeam.toUpperCase().equals("RED") || settings.autoTeam.toUpperCase().equals("BLUE") || settings.autoTeam.toUpperCase().equals("YELLOW")) { + val msg = SetPlayerTeamMessage.newBuilder().setTeam(TeamColor.valueOf(settings.autoTeam.toUpperCase())).build() + val req = ServerRequest(RequestType.SET_PLAYER_TEAM, msg); + ctx.api.getRequestHandler().sendServerRequests(req); + try { + val response = SetPlayerTeamResponseOuterClass.SetPlayerTeamResponse.parseFrom(req.data) + if (response.status == SetPlayerTeamResponseOuterClass.SetPlayerTeamResponse.Status.SUCCESS) { + Log.green("You are now in the ${settings.autoTeam.toUpperCase()} team!") + } + else { + Log.red("An error occured when trying to set your team") + } + } catch (e : InvalidProtocolBufferException) { + + } + } + else if(!settings.autoTeam.toUpperCase().equals("NEUTRAL")) { + Log.red("Unknow team in the config file!") + } + } } } From 736673711296a837a547de2fd75af5e77f7b898d Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sat, 27 Aug 2016 22:54:38 +0200 Subject: [PATCH 5/9] Add imports for auto team --- src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt index 17e6053c8..3e699d15b 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt @@ -19,6 +19,12 @@ import java.text.NumberFormat import java.time.LocalDateTime import java.time.temporal.ChronoUnit import java.util.* +import kotlin.reflect.jvm.internal.impl.protobuf.InvalidProtocolBufferException +import POGOProtos.Enums.TeamColorOuterClass.TeamColor +import POGOProtos.Networking.Requests.Messages.SetPlayerTeamMessageOuterClass.SetPlayerTeamMessage +import POGOProtos.Networking.Requests.RequestTypeOuterClass.RequestType +import com.pokegoapi.main.ServerRequest +import POGOProtos.Networking.Responses.SetPlayerTeamResponseOuterClass class UpdateProfile : Task { var lastLevelCheck: Int = 1 From 3743a19bf157647d60e68ba5eb89444b08ecd2d6 Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sat, 27 Aug 2016 23:14:13 +0200 Subject: [PATCH 6/9] Fix commas for auto join team settings --- src/main/kotlin/ink/abb/pogo/scraper/Settings.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt index 00a3c296c..eb469a757 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt @@ -150,7 +150,7 @@ class SettingsParser(val properties: Properties) { botTimeoutAfterMinutes = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_minutes", defaults.botTimeoutAfterMinutes, String::toInt), botTimeoutAfterCatchingPokemon = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_catching_pokemon", defaults.botTimeoutAfterCatchingPokemon, String::toInt), - botTimeoutAfterVisitingPokestops = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_visiting_pokestops", defaults.botTimeoutAfterVisitingPokestops, String::toInt) + botTimeoutAfterVisitingPokestops = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_visiting_pokestops", defaults.botTimeoutAfterVisitingPokestops, String::toInt), autoTeam = getPropertyIfSet("Auto team", "auto_team", defaults.autoTeam, String::toString) ) @@ -300,7 +300,7 @@ data class Settings( val botTimeoutAfterMinutes: Int = -1, val botTimeoutAfterCatchingPokemon:Int = -1, - val botTimeoutAfterVisitingPokestops:Int = -1 + val botTimeoutAfterVisitingPokestops:Int = -1, val autoTeam: String = "NEUTRAL" ) { From 4fa7fe20faeb7b838fb4a417b4cb78d62f6aa13f Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sun, 28 Aug 2016 11:37:49 +0200 Subject: [PATCH 7/9] Update UpdateProfile.kt --- .../abb/pogo/scraper/tasks/UpdateProfile.kt | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt index 3e699d15b..fbf2507fb 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt @@ -119,20 +119,19 @@ class UpdateProfile : Task { } if(ctx.api.playerProfile.playerData.team==TeamColor.NEUTRAL && ctx.api.playerProfile.stats.level>=5) { if(settings.autoTeam.toUpperCase().equals("RED") || settings.autoTeam.toUpperCase().equals("BLUE") || settings.autoTeam.toUpperCase().equals("YELLOW")) { - val msg = SetPlayerTeamMessage.newBuilder().setTeam(TeamColor.valueOf(settings.autoTeam.toUpperCase())).build() - val req = ServerRequest(RequestType.SET_PLAYER_TEAM, msg); - ctx.api.getRequestHandler().sendServerRequests(req); - try { - val response = SetPlayerTeamResponseOuterClass.SetPlayerTeamResponse.parseFrom(req.data) - if (response.status == SetPlayerTeamResponseOuterClass.SetPlayerTeamResponse.Status.SUCCESS) { - Log.green("You are now in the ${settings.autoTeam.toUpperCase()} team!") - } - else { - Log.red("An error occured when trying to set your team") - } - } catch (e : InvalidProtocolBufferException) { - - } + val msg = SetPlayerTeamMessage.newBuilder().setTeam(TeamColor.valueOf(settings.autoTeam.toUpperCase())).build() + val req = ServerRequest(RequestType.SET_PLAYER_TEAM, msg) + ctx.api.getRequestHandler().sendServerRequests(req) + try { + val response = SetPlayerTeamResponseOuterClass.SetPlayerTeamResponse.parseFrom(req.data) + if (response.status == SetPlayerTeamResponseOuterClass.SetPlayerTeamResponse.Status.SUCCESS) { + Log.green("You are now in the ${settings.autoTeam.toUpperCase()} team!") + } + else { + Log.red("An error occured when trying to set your team") + } + } catch (e : InvalidProtocolBufferException) { + } } else if(!settings.autoTeam.toUpperCase().equals("NEUTRAL")) { Log.red("Unknow team in the config file!") From 512e6f2bec3e56ab41bc4cbebd02cf4fed094f36 Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sat, 3 Sep 2016 18:05:43 +0200 Subject: [PATCH 8/9] Update UpdateProfile.kt --- src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt index eb045dfd4..c49474271 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt @@ -117,8 +117,8 @@ class UpdateProfile : Task { } catch (e: Exception) { Log.red("Failed to update profile and inventories") } - if(ctx.api.playerProfile.playerData.team==TeamColor.NEUTRAL && ctx.api.playerProfile.stats.level>=5) { - if(settings.autoTeam.toUpperCase().equals("RED") || settings.autoTeam.toUpperCase().equals("BLUE") || settings.autoTeam.toUpperCase().equals("YELLOW")) { + if (ctx.api.playerProfile.playerData.team==TeamColor.NEUTRAL && ctx.api.playerProfile.stats.level>=5) { + if (settings.autoTeam.toUpperCase().equals("RED") || settings.autoTeam.toUpperCase().equals("BLUE") || settings.autoTeam.toUpperCase().equals("YELLOW")) { val msg = SetPlayerTeamMessage.newBuilder().setTeam(TeamColor.valueOf(settings.autoTeam.toUpperCase())).build() val req = ServerRequest(RequestType.SET_PLAYER_TEAM, msg) ctx.api.getRequestHandler().sendServerRequests(req) @@ -131,7 +131,7 @@ class UpdateProfile : Task { Log.red("An error occured when trying to set your team") } } catch (e : InvalidProtocolBufferException) { - } + } } else if(!settings.autoTeam.toUpperCase().equals("NEUTRAL")) { Log.red("Unknow team in the config file!") From 0979a92fb30fb25abbbeae52b89a1466c1a03d96 Mon Sep 17 00:00:00 2001 From: Nashoba24 Date: Sat, 3 Sep 2016 18:07:42 +0200 Subject: [PATCH 9/9] Update Settings.kt --- src/main/kotlin/ink/abb/pogo/scraper/Settings.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt index 07dbfdc23..dd916b6b9 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt @@ -150,7 +150,7 @@ class SettingsParser(val properties: Properties) { botTimeoutAfterMinutes = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_minutes", defaults.botTimeoutAfterMinutes, String::toInt), botTimeoutAfterCatchingPokemon = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_catching_pokemon", defaults.botTimeoutAfterCatchingPokemon, String::toInt), botTimeoutAfterVisitingPokestops = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_visiting_pokestops", defaults.botTimeoutAfterVisitingPokestops, String::toInt), - + autoTeam = getPropertyIfSet("Auto team", "auto_team", defaults.autoTeam, String::toString) ) } @@ -300,7 +300,7 @@ data class Settings( val botTimeoutAfterMinutes: Int = -1, val botTimeoutAfterCatchingPokemon:Int = -1, val botTimeoutAfterVisitingPokestops:Int = -1, - + val autoTeam: String = "NEUTRAL" ) { fun withName(name: String): Settings {