diff --git a/jobs/refresh-ffxiv/refresh-ffxiv.go b/jobs/refresh-ffxiv/refresh-ffxiv.go deleted file mode 100644 index c8fc34ee..00000000 --- a/jobs/refresh-ffxiv/refresh-ffxiv.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "time" - - "github.com/animenotifier/arn" - "github.com/animenotifier/arn/stringutils" - "github.com/fatih/color" -) - -var ticker = time.NewTicker(1100 * time.Millisecond) - -func main() { - color.Yellow("Refreshing FFXIV information") - - defer color.Green("Finished.") - defer arn.Node.Close() - - for user := range arn.StreamUsers() { - if user.Accounts.FinalFantasyXIV.Nick == "" || user.Accounts.FinalFantasyXIV.Server == "" { - continue - } - - // Fetch new info - err := user.RefreshFFXIVInfo() - - if err != nil { - color.Red(err.Error()) - continue - } - - // Log it - stringutils.PrettyPrint(user.Accounts.FinalFantasyXIV) - - // Save in database - user.Save() - - // Wait for rate limiter - <-ticker.C - } -} diff --git a/jobs/refresh-games/ffxiv.go b/jobs/refresh-games/ffxiv.go new file mode 100644 index 00000000..d395c942 --- /dev/null +++ b/jobs/refresh-games/ffxiv.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "time" + + "github.com/animenotifier/arn" + "github.com/animenotifier/arn/stringutils" + "github.com/fatih/color" +) + +var tickerFFXIV = time.NewTicker(1100 * time.Millisecond) + +func ffxiv(user *arn.User) { + fmt.Println("[FFXIV]", user.Nick, user.Accounts.FinalFantasyXIV.Nick, user.Accounts.FinalFantasyXIV.Server) + + // Fetch new info + err := user.RefreshFFXIVInfo() + + if err != nil { + color.Red(err.Error()) + return + } + + // Log it + stringutils.PrettyPrint(user.Accounts.FinalFantasyXIV) + + // Save in database + user.Save() + + // Wait for rate limiter + <-tickerFFXIV.C +} diff --git a/jobs/refresh-games/osu.go b/jobs/refresh-games/osu.go new file mode 100644 index 00000000..618cd8d3 --- /dev/null +++ b/jobs/refresh-games/osu.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "time" + + "github.com/animenotifier/arn" + "github.com/animenotifier/arn/stringutils" + "github.com/fatih/color" +) + +var tickerOsu = time.NewTicker(500 * time.Millisecond) + +func osu(user *arn.User) { + fmt.Println("[Osu]", user.Nick, user.Accounts.Osu.Nick) + + // Fetch new info + err := user.RefreshOsuInfo() + + if err != nil { + color.Red(err.Error()) + return + } + + // Log it + stringutils.PrettyPrint(user.Accounts.Osu) + + // Save in database + user.Save() + + // Wait for rate limiter + <-tickerOsu.C +} diff --git a/jobs/refresh-games/overwatch.go b/jobs/refresh-games/overwatch.go new file mode 100644 index 00000000..08423717 --- /dev/null +++ b/jobs/refresh-games/overwatch.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "time" + + "github.com/animenotifier/arn" + "github.com/animenotifier/arn/stringutils" + "github.com/fatih/color" +) + +var tickerOW = time.NewTicker(1100 * time.Millisecond) + +func overwatch(user *arn.User) { + fmt.Println("[Overwatch]", user.Nick, user.Accounts.Overwatch.BattleTag) + + // Fetch new info + err := user.RefreshOverwatchInfo() + + if err != nil { + color.Red(err.Error()) + return + } + + // Log it + stringutils.PrettyPrint(user.Accounts.Overwatch) + + // Save in database + user.Save() + + // Wait for rate limiter + <-tickerOW.C +} diff --git a/jobs/refresh-games/refresh-games.go b/jobs/refresh-games/refresh-games.go new file mode 100644 index 00000000..791dabb9 --- /dev/null +++ b/jobs/refresh-games/refresh-games.go @@ -0,0 +1,27 @@ +package main + +import ( + "github.com/animenotifier/arn" + "github.com/fatih/color" +) + +func main() { + color.Yellow("Refreshing game information") + + defer color.Green("Finished.") + defer arn.Node.Close() + + for user := range arn.StreamUsers() { + if user.Accounts.Osu.Nick != "" { + osu(user) + } + + if user.Accounts.Overwatch.BattleTag != "" { + overwatch(user) + } + + if user.Accounts.FinalFantasyXIV.Nick != "" && user.Accounts.FinalFantasyXIV.Server != "" { + ffxiv(user) + } + } +} diff --git a/jobs/refresh-osu/refresh-osu.go b/jobs/refresh-osu/refresh-osu.go deleted file mode 100644 index 59cdfb90..00000000 --- a/jobs/refresh-osu/refresh-osu.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "time" - - "github.com/animenotifier/arn" - "github.com/animenotifier/arn/stringutils" - "github.com/fatih/color" -) - -var ticker = time.NewTicker(500 * time.Millisecond) - -func main() { - color.Yellow("Refreshing osu information") - - defer color.Green("Finished.") - defer arn.Node.Close() - - for user := range arn.StreamUsers() { - if user.Accounts.Osu.Nick == "" { - continue - } - - // Fetch new info - err := user.RefreshOsuInfo() - - if err != nil { - color.Red(err.Error()) - continue - } - - // Log it - stringutils.PrettyPrint(user.Accounts.Osu) - - // Save in database - user.Save() - - // Wait for rate limiter - <-ticker.C - } -} diff --git a/pages/editor/jobs/jobs.go b/pages/editor/jobs/jobs.go index edd83002..504355ca 100644 --- a/pages/editor/jobs/jobs.go +++ b/pages/editor/jobs/jobs.go @@ -18,17 +18,8 @@ var jobInfo = map[string]*utils.JobInfo{ "twist": &utils.JobInfo{ Name: "twist", }, - "refresh-osu": &utils.JobInfo{ - Name: "refresh-osu", - }, - "mal-download": &utils.JobInfo{ - Name: "mal-download", - }, - "mal-parse": &utils.JobInfo{ - Name: "mal-parse", - }, - "mal-sync": &utils.JobInfo{ - Name: "mal-sync", + "refresh-games": &utils.JobInfo{ + Name: "refresh-games", }, "test": &utils.JobInfo{ Name: "test",