This commit is contained in:
shoopea 2020-01-16 19:25:13 +08:00
parent ecc9b8a180
commit 5e25478137
3 changed files with 25 additions and 19 deletions

View File

@ -103,7 +103,6 @@ func cronSaveClients() {
logOnError(err, "cronSaveClients : Marshal") logOnError(err, "cronSaveClients : Marshal")
pb := pretty.Pretty(b) pb := pretty.Pretty(b)
log.Printf("cronSaveClients :\n%s\n", string(pb))
err = ioutil.WriteFile("./clients_new.json", pb, 0644) err = ioutil.WriteFile("./clients_new.json", pb, 0644)
logOnError(err, "cronSaveClients : WriteFile") logOnError(err, "cronSaveClients : WriteFile")

18
main.go
View File

@ -86,23 +86,7 @@ func main() {
initDB() initDB()
} }
initCache() initCache(*initdb)
if *initdb {
_, _ = addObjCastle(`🦌`, `Deerhorn`)
_, _ = addObjCastle(`🐉`, `Dragonscale`)
_, _ = addObjCastle(`🦅`, `Highnest`)
_, _ = addObjCastle(`🌑`, `Moonlight`)
_, _ = addObjCastle(`🥔`, `Potato`)
_, _ = addObjCastle(`🦈`, `Sharkteeth`)
_, _ = addObjCastle(`🐺`, `Wolfpack`)
_, _ = addObjCastle(``, `Unknown`)
_, _ = addObjGuild(``, `No Guild`)
}
log.Println("Caching castles ..")
err = loadObjCastle()
logOnError(err, "initCache : caching castles")
// Registering bot // Registering bot
bot, err := tb.NewBot(tb.Settings{ bot, err := tb.NewBot(tb.Settings{

25
obj.go
View File

@ -30,7 +30,7 @@ var (
muxObjJob sync.Mutex muxObjJob sync.Mutex
) )
func initCache() { func initCache(initDB bool) {
var err error var err error
log.Println("Caching obj_type ..") log.Println("Caching obj_type ..")
@ -66,6 +66,29 @@ func initCache() {
err = loadObjJob() err = loadObjJob()
logOnError(err, "initCache : caching jobs") logOnError(err, "initCache : caching jobs")
if initDB {
_, _ = addObjCastle(`🦌`, `Deerhorn`)
_, _ = addObjCastle(`🐉`, `Dragonscale`)
_, _ = addObjCastle(`🦅`, `Highnest`)
_, _ = addObjCastle(`🌑`, `Moonlight`)
_, _ = addObjCastle(`🥔`, `Potato`)
_, _ = addObjCastle(`🦈`, `Sharkteeth`)
_, _ = addObjCastle(`🐺`, `Wolfpack`)
_, _ = addObjCastle(``, `Unknown`)
_, _ = addObjGuild(``, `No Guild`)
}
log.Println("Caching castles ..")
err = loadObjCastle()
logOnError(err, "initCache : caching castles")
log.Println("Caching clients ..")
err = loadClients()
if initDB {
}
} }
func loadObjType() error { func loadObjType() error {