Updated jobs

This commit is contained in:
Eduard Urbach 2018-11-01 12:28:45 +09:00
parent b5f6f2e448
commit cbfc08a796
7 changed files with 128 additions and 93 deletions

View File

@ -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
}
}

View File

@ -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
}

33
jobs/refresh-games/osu.go Normal file
View File

@ -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
}

View File

@ -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
}

View File

@ -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)
}
}
}

View File

@ -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
}
}

View File

@ -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",