diff options
Diffstat (limited to 'wat/db.go')
-rw-r--r-- | wat/db.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -65,8 +65,12 @@ func NewWatDb() *WatDb { func (w *WatDb) User(nick, host string, create bool) Player { var player Player + query := "nick = ?" + if host != "" { + query = query + " or host = ?" + } // Try and get a user - if err := w.db.First(&player, "nick = ? or host = ?", nick, host).Error; err != nil && create { + if err := w.db.First(&player, query, nick, host).Error; err != nil && create { fmt.Printf("Creating user: %s\n", err.Error()) // No user, make another player.Nick = nick |