Move logic into alreadyHandled function
This commit is contained in:
parent
bd24198b05
commit
894ad95d73
12
main.go
12
main.go
@ -49,10 +49,10 @@ func tickGameStart(c *sn.Client) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if exists, err := db.ItemHasReply(n.Item.Id, meId); err != nil {
|
if handled, err := alreadyHandled(n.Item.Id); err != nil {
|
||||||
log.Printf("failed to check for existing reply to game start in item %d: %v\n", n.Item.Id, err)
|
log.Printf("failed to check for existing reply to game start in item %d: %v\n", n.Item.Id, err)
|
||||||
continue
|
continue
|
||||||
} else if exists {
|
} else if handled {
|
||||||
// TODO: check if move changed
|
// TODO: check if move changed
|
||||||
log.Printf("reply to game start in item %d already exists\n", n.Item.Id)
|
log.Printf("reply to game start in item %d already exists\n", n.Item.Id)
|
||||||
continue
|
continue
|
||||||
@ -98,10 +98,10 @@ func tickGameProgress(c *sn.Client) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if exists, err := db.ItemHasReply(n.Item.Id, meId); err != nil {
|
if handled, err := alreadyHandled(n.Item.Id); err != nil {
|
||||||
log.Printf("failed to check for existing reply to game update in item %d: %v\n", n.Item.Id, err)
|
log.Printf("failed to check for existing reply to game update in item %d: %v\n", n.Item.Id, err)
|
||||||
continue
|
continue
|
||||||
} else if exists {
|
} else if handled {
|
||||||
// TODO: check if move changed
|
// TODO: check if move changed
|
||||||
log.Printf("reply to game update in item %d already exists\n", n.Item.Id)
|
log.Printf("reply to game update in item %d already exists\n", n.Item.Id)
|
||||||
continue
|
continue
|
||||||
@ -296,3 +296,7 @@ func isRecent(t time.Time) bool {
|
|||||||
x := time.Now().Add(-30 * time.Second)
|
x := time.Now().Add(-30 * time.Second)
|
||||||
return t.After(x)
|
return t.After(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func alreadyHandled(id int) (bool, error) {
|
||||||
|
return db.ItemHasReply(id, meId)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user