test
This commit is contained in:
parent
8ac2f43bd8
commit
b7d466779a
2
main.go
2
main.go
@ -101,6 +101,8 @@ func main() {
|
||||
logOnError(err, "Caching castles")
|
||||
err = loadObjGuild()
|
||||
logOnError(err, "Caching guilds")
|
||||
err = loadObjUser()
|
||||
logOnError(err, "Caching user")
|
||||
|
||||
// Registering bot
|
||||
b, err := tb.NewBot(tb.Settings{
|
||||
|
17
obj.go
17
obj.go
@ -8,6 +8,7 @@ import (
|
||||
var (
|
||||
cacheObjCastle map[string]ChatWarsCastle
|
||||
cacheObjGuild map[string]ChatWarsGuild
|
||||
cacheObjUser map[string]ChatWarsUser
|
||||
)
|
||||
|
||||
func getObjTypeId(objId int64) (int64, error) {
|
||||
@ -444,28 +445,26 @@ func getObjUserID(s string) int64 {
|
||||
func loadObjUser() error {
|
||||
var (
|
||||
id int64
|
||||
tag string
|
||||
name string
|
||||
)
|
||||
|
||||
cacheObjUser = make(map[string]ChatWarsGuild)
|
||||
cacheObjUser = make(map[string]ChatWarsUser)
|
||||
|
||||
users, err := db.Query(`SELECT og.obj_id, og.tag, og.name FROM obj_guild og;`)
|
||||
users, err := db.Query(`SELECT ou.obj_id, ou.name FROM obj_user ou;`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer users.Close()
|
||||
|
||||
for users.Next() {
|
||||
err = users.Scan(&id, &tag, &name)
|
||||
err = users.Scan(&id, &name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
g := new(ChatWarsUser)
|
||||
g.ObjID64 = id
|
||||
g.Tag = tag
|
||||
g.Name = name
|
||||
cacheObjUser[tag] = *g
|
||||
u := new(ChatWarsUser)
|
||||
u.ObjID64 = id
|
||||
u.Name = name
|
||||
cacheObjUser[tag] = *u
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user