2017-10-05 11:55:46 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/fatih/color"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Shell parameters
|
|
|
|
var confirmed bool
|
|
|
|
|
|
|
|
// Shell flags
|
|
|
|
func init() {
|
|
|
|
flag.BoolVar(&confirmed, "confirm", false, "Confirm that you really want to execute this.")
|
|
|
|
flag.Parse()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
if !confirmed {
|
|
|
|
color.Green("Please run this command with -confirm option if you really want to reset the balance of all users.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
color.Yellow("Resetting balance of all users to 0")
|
2017-11-01 19:11:05 +00:00
|
|
|
defer arn.Node.Close()
|
2017-10-05 11:55:46 +00:00
|
|
|
|
|
|
|
// Iterate over the stream
|
2017-11-01 19:11:05 +00:00
|
|
|
for user := range arn.StreamUsers() {
|
2017-10-05 11:55:46 +00:00
|
|
|
user.Balance = 0
|
2017-11-01 19:11:05 +00:00
|
|
|
user.Save()
|
2017-10-05 11:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
color.Green("Finished.")
|
|
|
|
}
|