2017-10-04 06:12:12 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/fatih/color"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
color.Yellow("Adding inventories to users who don't have one")
|
|
|
|
|
|
|
|
// Get a stream of all users
|
|
|
|
allUsers, err := arn.StreamUsers()
|
|
|
|
arn.PanicOnError(err)
|
|
|
|
|
|
|
|
// Iterate over the stream
|
|
|
|
for user := range allUsers {
|
2017-10-05 07:39:37 +00:00
|
|
|
// exists, err := arn.DB.Exists("Inventory", user.ID)
|
2017-10-04 06:12:12 +00:00
|
|
|
|
2017-10-05 07:39:37 +00:00
|
|
|
// if err != nil || exists {
|
|
|
|
// continue
|
|
|
|
// }
|
2017-10-04 06:12:12 +00:00
|
|
|
|
|
|
|
fmt.Println(user.Nick)
|
|
|
|
|
|
|
|
inventory := arn.NewInventory(user.ID)
|
2017-10-05 07:39:37 +00:00
|
|
|
|
|
|
|
// TEST
|
|
|
|
inventory.AddItem("anime-support-ticket", 50)
|
|
|
|
inventory.AddItem("pro-account-24", 30)
|
|
|
|
|
2017-10-04 06:12:12 +00:00
|
|
|
err = arn.DB.Set("Inventory", inventory.UserID, inventory)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
color.Red(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
color.Green("Finished.")
|
|
|
|
}
|