Browse Source

change special giveaways detection

instead of assuming there are 3 specials maximum compare last page's
wishlist ids to current page
master
Roshless 7 months ago
parent
commit
9025c78fe9
2 changed files with 20 additions and 2 deletions
  1. +3
    -2
      main.go
  2. +17
    -0
      slices.go

+ 3
- 2
main.go View File

@@ -18,6 +18,7 @@ func enterGiveaways(cookie *http.Cookie, enterWishlist bool) {
fmt.Println("all")
}
page := 1
var lastGiveaways []string

for {
var index string
@@ -44,11 +45,11 @@ func enterGiveaways(cookie *http.Cookie, enterWishlist bool) {
giveaways := convert2DsliceTo1D(giveaways2D)
giveaways = removeDuplicatesUnordered(giveaways)

if len(giveaways) <= 3 && enterWishlist {
// Note to myself: I think they changed it from 2
if equalStringSlice(lastGiveaways, giveaways) && enterWishlist {
fmt.Println("No more games on wishlist")
return
}
lastGiveaways = giveaways

for _, givewayID := range giveaways {
pointsInt, err = strconv.ParseInt(points, 10, 16)

+ 17
- 0
slices.go View File

@@ -1,5 +1,7 @@
package main

import "sort"

func convert2DsliceTo1D(sliceTwoDim [][]string) []string {
var returnSlice []string
for _, element := range sliceTwoDim {
@@ -23,3 +25,18 @@ func removeDuplicatesUnordered(elements []string) []string {
}
return result
}

func equalStringSlice(a, b []string) bool {
if len(a) != len(b) {
return false
}

sort.Strings(a)
sort.Strings(b)
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}

Loading…
Cancel
Save