commit e967d02

Simon Ser  ·  2020-11-06 21:33:57 +0000 UTC
parent a370adb
Default user/real to nickname if unspecified

While at it, error out if nick is unspecified instead of sending a
broken command to the server.
1 files changed,  +10, -0
+10, -0
 1@@ -181,6 +181,16 @@ func NewSession(conn io.ReadWriteCloser, params SessionParams) (*Session, error)
 2 		chBatches:     map[string]HistoryEvent{},
 3 	}
 4 
 5+	if s.nick == "" {
 6+		return nil, errors.New("no nickname specified")
 7+	}
 8+	if s.user == "" {
 9+		s.user = s.nick
10+	}
11+	if s.real == "" {
12+		s.real = s.nick
13+	}
14+
15 	s.running.Store(true)
16 
17 	err := s.send("CAP LS 302\r\nNICK %s\r\nUSER %s 0 * :%s\r\n", s.nick, s.user, s.real)