commit 66031ed

Hubert Hirtz  ·  2020-08-19 19:00:17 +0000 UTC
parent b0a5b6c
ui: Show the nick when senpai registers with a different one
3 files changed,  +7, -6
M app.go
M app.go
+5, -1
 1@@ -100,7 +100,11 @@ func (app *App) handleIRCEvent(ev irc.Event) {
 2 		}
 3 		app.win.AddLine(ui.Home, ui.NewLineNow(head, ev.Message))
 4 	case irc.RegisteredEvent:
 5-		app.win.AddLine(ui.Home, ui.NewLineNow("--", "Connected to the server"))
 6+		line := "Connected to the server"
 7+		if app.s.Nick() != app.cfg.Nick {
 8+			line += " as " + app.s.Nick()
 9+		}
10+		app.win.AddLine(ui.Home, ui.NewLineNow("--", line))
11 		if app.cfg.Highlights == nil {
12 			app.highlights[0] = app.s.NickCf()
13 		}
+1, -4
 1@@ -479,10 +479,7 @@ func (s *Session) handleStart(msg Message) (err error) {
 2 			s.handle(msg)
 3 		}
 4 	case errNicknameinuse:
 5-		s.nick = s.nick + "_"
 6-		s.nickCf = s.nickCf + "_"
 7-
 8-		err = s.send("NICK %s\r\n", s.nick)
 9+		err = s.send("NICK %s_\r\n", msg.Params[1])
10 		if err != nil {
11 			return
12 		}
+1, -1
1@@ -236,7 +236,7 @@ func (msg *Message) IsValid() bool {
2 	switch msg.Command {
3 	case "AUTHENTICATE", "PING", "PONG":
4 		return 1 <= len(msg.Params)
5-	case rplEndofnames, rplLoggedout, rplMotd, rplNotopic, rplWelcome, rplYourhost:
6+	case rplEndofnames, rplLoggedout, rplMotd, errNicknameinuse, rplNotopic, rplWelcome, rplYourhost:
7 		return 2 <= len(msg.Params)
8 	case rplIsupport, rplLoggedin, rplTopic:
9 		return 3 <= len(msg.Params)