From e967d02466479fef65cf37b97f0f7b8f0be6daf4 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 6 Nov 2020 21:33:57 +0000 Subject: 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. --- irc/states.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'irc') diff --git a/irc/states.go b/irc/states.go index 027eda2..c702c43 100644 --- a/irc/states.go +++ b/irc/states.go @@ -181,6 +181,16 @@ func NewSession(conn io.ReadWriteCloser, params SessionParams) (*Session, error) chBatches: map[string]HistoryEvent{}, } + if s.nick == "" { + return nil, errors.New("no nickname specified") + } + if s.user == "" { + s.user = s.nick + } + if s.real == "" { + s.real = s.nick + } + s.running.Store(true) err := s.send("CAP LS 302\r\nNICK %s\r\nUSER %s 0 * :%s\r\n", s.nick, s.user, s.real) -- cgit v1.2.3