summaryrefslogtreecommitdiffstats
path: root/wat/db.go
diff options
context:
space:
mode:
Diffstat (limited to 'wat/db.go')
-rw-r--r--wat/db.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/wat/db.go b/wat/db.go
index 85a598b..8971223 100644
--- a/wat/db.go
+++ b/wat/db.go
@@ -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