summaryrefslogtreecommitdiff
path: root/irc
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-11-06 21:33:57 +0000
committerHubert Hirtz <hubert@hirtz.pm>2020-11-06 22:42:02 +0100
commite967d02466479fef65cf37b97f0f7b8f0be6daf4 (patch)
treefaeec977ae5aeaac701987d2637682adccdcf10c /irc
parentirc: Fix requestHistory by making it use UTC (diff)
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.
Diffstat (limited to 'irc')
-rw-r--r--irc/states.go10
1 files changed, 10 insertions, 0 deletions
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)