2017-07-02 13:11:42 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/animenotifier/arn"
|
2018-04-19 20:15:05 +00:00
|
|
|
"github.com/animenotifier/arn/stringutils"
|
2017-07-02 13:11:42 +00:00
|
|
|
"github.com/fatih/color"
|
|
|
|
)
|
|
|
|
|
2018-03-21 04:15:03 +00:00
|
|
|
var ticker = time.NewTicker(500 * time.Millisecond)
|
|
|
|
|
2017-07-02 13:11:42 +00:00
|
|
|
func main() {
|
|
|
|
color.Yellow("Refreshing osu information")
|
|
|
|
|
2018-03-21 04:15:03 +00:00
|
|
|
defer color.Green("Finished.")
|
|
|
|
defer arn.Node.Close()
|
2017-07-02 13:11:42 +00:00
|
|
|
|
2017-11-02 08:26:05 +00:00
|
|
|
for user := range arn.StreamUsers() {
|
2018-03-21 04:15:03 +00:00
|
|
|
if user.Accounts.Osu.Nick == "" {
|
|
|
|
continue
|
2017-07-02 13:11:42 +00:00
|
|
|
}
|
|
|
|
|
2018-03-21 04:15:03 +00:00
|
|
|
// Fetch new info
|
|
|
|
err := user.RefreshOsuInfo()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
color.Red(err.Error())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// Log it
|
2018-04-19 20:15:05 +00:00
|
|
|
stringutils.PrettyPrint(user.Accounts.Osu)
|
2018-03-21 04:15:03 +00:00
|
|
|
|
|
|
|
// Save in database
|
|
|
|
user.Save()
|
|
|
|
|
2017-07-02 13:11:42 +00:00
|
|
|
// Wait for rate limiter
|
|
|
|
<-ticker.C
|
|
|
|
}
|
|
|
|
}
|