Added clones list
This commit is contained in:
parent
54e5553e4d
commit
a74aa529b0
1 changed files with 98 additions and 3 deletions
101
main.go
101
main.go
|
@ -25,6 +25,7 @@ import (
|
||||||
|
|
||||||
ESI "./client"
|
ESI "./client"
|
||||||
|
|
||||||
|
ESIClones "./client/clones"
|
||||||
ESILocation "./client/location"
|
ESILocation "./client/location"
|
||||||
ESIPlanetaryInteraction "./client/planetary_interaction"
|
ESIPlanetaryInteraction "./client/planetary_interaction"
|
||||||
ESISkills "./client/skills"
|
ESISkills "./client/skills"
|
||||||
|
@ -61,6 +62,7 @@ var (
|
||||||
"esi-planets.manage_planets.v1",
|
"esi-planets.manage_planets.v1",
|
||||||
"esi-wallet.read_character_wallet.v1",
|
"esi-wallet.read_character_wallet.v1",
|
||||||
"esi-location.read_location.v1",
|
"esi-location.read_location.v1",
|
||||||
|
"esi-clones.read_clones.v1",
|
||||||
},
|
},
|
||||||
Endpoint: oauth2.Endpoint{
|
Endpoint: oauth2.Endpoint{
|
||||||
AuthURL: "https://login.eveonline.com/oauth/authorize/",
|
AuthURL: "https://login.eveonline.com/oauth/authorize/",
|
||||||
|
@ -290,6 +292,83 @@ func printCharacterInformation(swaggerclient *ESI.App, m *Character) {
|
||||||
stationName,
|
stationName,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cloCallParams := ESIClones.NewGetCharactersCharacterIDClonesParams()
|
||||||
|
cloCallParams.WithCharacterID(m.CharacterID)
|
||||||
|
|
||||||
|
cloresponse, cloerr := swaggerclient.Clones.GetCharactersCharacterIDClones(cloCallParams, nil)
|
||||||
|
if cloerr != nil {
|
||||||
|
fmt.Println("Error while getting the current character clones.")
|
||||||
|
log.Fatalf("Got error on GetCharactersCharacterIDClones: %s", cloerr)
|
||||||
|
}
|
||||||
|
|
||||||
|
clones := cloresponse.Payload.JumpClones
|
||||||
|
|
||||||
|
fmt.Printf("\nClones: \n")
|
||||||
|
for _, clone := range clones {
|
||||||
|
sInfo, _ := getStructureStationInfo(swaggerclient, clone.LocationType, clone.LocationID)
|
||||||
|
|
||||||
|
fmt.Printf(" %s, %s, %s\n ",
|
||||||
|
sInfo.Name,
|
||||||
|
sInfo.System.ConstellationName,
|
||||||
|
sInfo.System.RegionName,
|
||||||
|
)
|
||||||
|
|
||||||
|
implantNames := getUniverseNames(swaggerclient, &clone.Implants)
|
||||||
|
for _, implant := range clone.Implants {
|
||||||
|
implantName := implantNames[implant]
|
||||||
|
fmt.Printf(" %s, ", implantName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type structureInfo struct {
|
||||||
|
ID int64
|
||||||
|
Name string
|
||||||
|
SystemID int32
|
||||||
|
System solarSystemInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func getStructureStationInfo(swaggerclient *ESI.App, typeID string, ID int64) (*structureInfo, error) {
|
||||||
|
locationName := getCachedDataSub64(ID, "name")
|
||||||
|
locationSystem := getCachedDataIntSub64(ID, "system")
|
||||||
|
|
||||||
|
if locationName != "" && locationSystem > 0 {
|
||||||
|
var sInfo structureInfo
|
||||||
|
|
||||||
|
sInfo.ID = ID
|
||||||
|
sInfo.Name = locationName
|
||||||
|
sInfo.System = getSolarSystemInformation(swaggerclient, locationSystem)
|
||||||
|
|
||||||
|
return &sInfo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if typeID == "station" {
|
||||||
|
stacallParams := ESIUniverse.NewGetUniverseStationsStationIDParams()
|
||||||
|
stacallParams.WithStationID(int32(ID))
|
||||||
|
|
||||||
|
staresponse, staerr := swaggerclient.Universe.GetUniverseStationsStationID(stacallParams)
|
||||||
|
if staerr != nil {
|
||||||
|
log.Printf("Got error on GetCharactersCharacterIDClones: %s", staerr)
|
||||||
|
return nil, staerr
|
||||||
|
}
|
||||||
|
|
||||||
|
staInfo := staresponse.Payload
|
||||||
|
|
||||||
|
var sInfo structureInfo
|
||||||
|
|
||||||
|
sInfo.ID = int64(*staInfo.StationID)
|
||||||
|
sInfo.Name = *staInfo.Name
|
||||||
|
sInfo.SystemID = *staInfo.SystemID
|
||||||
|
sInfo.System = getSolarSystemInformation(swaggerclient, sInfo.SystemID)
|
||||||
|
|
||||||
|
putCacheDataSub64(sInfo.ID, "name", sInfo.Name)
|
||||||
|
putCacheDataIntSub64(sInfo.ID, "system", sInfo.SystemID)
|
||||||
|
|
||||||
|
return &sInfo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type byPIPinType []*ESIPlanetaryInteraction.PinsItems0
|
type byPIPinType []*ESIPlanetaryInteraction.PinsItems0
|
||||||
|
@ -338,14 +417,14 @@ func printCharacterPlanets(swaggerclient *ESI.App, m *Character) {
|
||||||
pcallParam := ESIPlanetaryInteraction.NewGetCharactersCharacterIDPlanetsPlanetIDParams()
|
pcallParam := ESIPlanetaryInteraction.NewGetCharactersCharacterIDPlanetsPlanetIDParams()
|
||||||
pcallParam.WithCharacterID(m.CharacterID).WithPlanetID(*planet.PlanetID)
|
pcallParam.WithCharacterID(m.CharacterID).WithPlanetID(*planet.PlanetID)
|
||||||
|
|
||||||
solarSystemInfo := getSolarSystemInformation(swaggerclient, *planet.SolarSystemID)
|
planetSystemInfo := getSolarSystemInformation(swaggerclient, *planet.SolarSystemID)
|
||||||
|
|
||||||
planetName := getPlanetInformation(swaggerclient, *planet.PlanetID)
|
planetName := getPlanetInformation(swaggerclient, *planet.PlanetID)
|
||||||
|
|
||||||
fmt.Printf("Planet %s, %s, %s - Type %s, Lvl %d - Updated %s\n",
|
fmt.Printf("Planet %s, %s, %s - Type %s, Lvl %d - Updated %s\n",
|
||||||
planetName.PlanetName,
|
planetName.PlanetName,
|
||||||
solarSystemInfo.ConstellationName,
|
planetSystemInfo.ConstellationName,
|
||||||
solarSystemInfo.RegionName,
|
planetSystemInfo.RegionName,
|
||||||
*planet.PlanetType,
|
*planet.PlanetType,
|
||||||
*planet.UpgradeLevel,
|
*planet.UpgradeLevel,
|
||||||
time.Time(*planet.LastUpdate).Format(defaultDateFormat),
|
time.Time(*planet.LastUpdate).Format(defaultDateFormat),
|
||||||
|
@ -662,6 +741,14 @@ func getCachedDataSub(key int32, subkey string) string {
|
||||||
return getCachedData(fmt.Sprintf("%d.%s", key, subkey))
|
return getCachedData(fmt.Sprintf("%d.%s", key, subkey))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCachedDataIntSub64(key int64, subkey string) int32 {
|
||||||
|
return getCachedDataInt(fmt.Sprintf("%d.%s", key, subkey))
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCachedDataSub64(key int64, subkey string) string {
|
||||||
|
return getCachedData(fmt.Sprintf("%d.%s", key, subkey))
|
||||||
|
}
|
||||||
|
|
||||||
func getCachedDataInt(key string) int32 {
|
func getCachedDataInt(key string) int32 {
|
||||||
strVal := getCachedData(key)
|
strVal := getCachedData(key)
|
||||||
|
|
||||||
|
@ -710,6 +797,14 @@ func putCacheDataSub(key int32, subkey string, value string) {
|
||||||
putCacheData(fmt.Sprintf("%d.%s", key, subkey), value)
|
putCacheData(fmt.Sprintf("%d.%s", key, subkey), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func putCacheDataIntSub64(key int64, subkey string, value int32) {
|
||||||
|
putCacheDataSub64(key, subkey, fmt.Sprintf("%d", value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func putCacheDataSub64(key int64, subkey string, value string) {
|
||||||
|
putCacheData(fmt.Sprintf("%d.%s", key, subkey), value)
|
||||||
|
}
|
||||||
|
|
||||||
func putCacheData(key string, value string) {
|
func putCacheData(key string, value string) {
|
||||||
db, err := sql.Open("sqlite3", *cacheDBPath)
|
db, err := sql.Open("sqlite3", *cacheDBPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Reference in a new issue