Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Auto join team #1245

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion json-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"waitTimeMax" : 0,
"botTimeoutAfterMinutes" : -1,
"botTimeoutAfterCatchingPokemon" : -1,
"botTimeoutAfterVisitingPokestops" : -1
"botTimeoutAfterVisitingPokestops" : -1,
"autoTeam" : "NEUTRAL"
}

8 changes: 6 additions & 2 deletions src/main/kotlin/ink/abb/pogo/scraper/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ 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)
)
}

Expand Down Expand Up @@ -297,7 +299,9 @@ data class Settings(

val botTimeoutAfterMinutes: Int = -1,
val botTimeoutAfterCatchingPokemon:Int = -1,
val botTimeoutAfterVisitingPokestops:Int = -1
val botTimeoutAfterVisitingPokestops:Int = -1,

val autoTeam: String = "NEUTRAL"
) {
fun withName(name: String): Settings {
this.name = name
Expand Down
26 changes: 26 additions & 0 deletions src/main/kotlin/ink/abb/pogo/scraper/tasks/UpdateProfile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -111,5 +117,25 @@ 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!")
}
}
}
}