commit 642e94b

Ferass El Hafidi  ·  2026-07-23 18:08:29 +0000 UTC
parent e52876a
Optionally show quit and part messages

These are shown by default, enable `quitmessages` in the config
file to show them.

Also differenciate between a quit and a part by showing an "x" next
to the nickname instead of a "-" for a quit.

The way this is implemented will hide the following quit messages:

 * "connection closed"
 * "Remote host closed connection"
 * "Quit: "
 * "" (empty)

Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
5 files changed,  +54, -6
M app.go
M app.go
+16, -2
 1@@ -201,7 +201,7 @@ func NewApp(cfg Config) (app *App, err error) {
 2 		AutoComplete: func(cursorIdx int, text []rune) []ui.Completion {
 3 			return app.completions(cursorIdx, text)
 4 		},
 5-		Mouse: mouse,
 6+		Mouse:   mouse,
 7 		Buttons: buttons,
 8 		MergeLine: func(former *ui.Line, addition ui.Line) {
 9 			app.mergeLine(former, addition)
10@@ -1888,11 +1888,20 @@ func (app *App) formatEvent(ev irc.Event) ui.Line {
11 		body.SetStyle(vaxis.Style{
12 			Foreground: ui.ColorRed,
13 		})
14-		body.WriteByte('-')
15+		body.WriteByte('x')
16 		body.SetStyle(vaxis.Style{
17 			Foreground: app.cfg.Colors.Status,
18 		})
19 		body.WriteString(ev.User)
20+		if app.cfg.QuitMessages && ev.Message != "" &&
21+			// Few checks for useless messages
22+			ev.Message != "Quit: " && ev.Message != "Client Quit" &&
23+			ev.Message != "connection closed" &&
24+			ev.Message != "Remote host closed the connection" {
25+			body.WriteString(" (")
26+			body.WriteString(ev.Message)
27+			body.WriteByte(')')
28+		}
29 		return ui.Line{
30 			At:        ev.Time,
31 			Head:      ui.ColorString("--", app.cfg.Colors.Status),
32@@ -1912,6 +1921,11 @@ func (app *App) formatEvent(ev irc.Event) ui.Line {
33 			Foreground: app.cfg.Colors.Status,
34 		})
35 		body.WriteString(ev.User)
36+		if app.cfg.QuitMessages && ev.Message != "" {
37+			body.WriteString(" (")
38+			body.WriteString(ev.Message)
39+			body.WriteByte(')')
40+		}
41 		return ui.Line{
42 			At:        ev.Time,
43 			Head:      ui.ColorString("--", app.cfg.Colors.Status),
+11, -0
 1@@ -112,6 +112,7 @@ type Config struct {
 2 	ChanColEnabled   bool
 3 	MemberColWidth   int
 4 	MemberColEnabled bool
 5+	QuitMessages     bool
 6 	TextMaxWidth     int
 7 	StatusEnabled    bool
 8 	Shortcuts        map[string][]string
 9@@ -157,6 +158,7 @@ func Defaults() Config {
10 		ChanColEnabled:   true,
11 		MemberColWidth:   16,
12 		MemberColEnabled: true,
13+		QuitMessages:     true,
14 		TextMaxWidth:     0,
15 		StatusEnabled:    true,
16 		Colors: ui.ConfigColors{
17@@ -483,6 +485,15 @@ func unmarshal(filename string, cfg *Config) (err error) {
18 				}
19 				cfg.Shortcuts[child.Name] = child.Params
20 			}
21+		case "quitmessages":
22+			var quitmessages string
23+			if err := d.ParseParams(&quitmessages); err != nil {
24+				return err
25+			}
26+
27+			if cfg.QuitMessages, err = strconv.ParseBool(quitmessages); err != nil {
28+				return err
29+			}
30 		case "debug":
31 			var debug string
32 			if err := d.ParseParams(&debug); err != nil {
+3, -0
 1@@ -126,6 +126,9 @@ pane-widths {
 2 *mouse*
 3 	Enable or disable mouse support.  Defaults to true.
 4 
 5+*quitmessages*
 6+	Enable or disable showing quit and part messages.  Defaults to false.
 7+
 8 *nick-prefix*
 9 	Show the speaker's channel-membership prefix (e.g. *@* for an operator,
10 	*+* for a voiced user) next to their nick on each message in a channel
+2, -0
 1@@ -48,12 +48,14 @@ type UserPartEvent struct {
 2 	User    string
 3 	Channel string
 4 	Time    time.Time
 5+	Message string
 6 }
 7 
 8 type UserQuitEvent struct {
 9 	User     string
10 	Channels []string
11 	Time     time.Time
12+	Message string
13 }
14 
15 type UserOnlineEvent struct {
+22, -4
 1@@ -1039,8 +1039,15 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
 2 		}
 3 	case "PART":
 4 		var channel string
 5-		if err := msg.ParseParams(&channel); err != nil {
 6-			return nil, err
 7+		var partmessage string
 8+		if len(msg.Params) == 2 {
 9+			if err := msg.ParseParams(&channel, &partmessage); err != nil {
10+				return nil, err
11+			}
12+		} else {
13+			if err := msg.ParseParams(&channel); err != nil {
14+				return nil, err
15+			}
16 		}
17 
18 		if playback {
19@@ -1048,6 +1055,7 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
20 				User:    msg.Prefix.Name,
21 				Channel: channel,
22 				Time:    msg.TimeOrNow(),
23+				Message: partmessage,
24 			}, nil
25 		}
26 
27@@ -1116,10 +1124,19 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
28 			}
29 		}
30 	case "QUIT":
31+		var quitmessage string
32+
33+		if len(msg.Params) == 1 {
34+			if err := msg.ParseParams(&quitmessage); err != nil {
35+				return nil, err
36+			}
37+		}
38+
39 		if playback {
40 			return UserQuitEvent{
41-				User: msg.Prefix.Name,
42-				Time: msg.TimeOrNow(),
43+				User:    msg.Prefix.Name,
44+				Time:    msg.TimeOrNow(),
45+				Message: quitmessage,
46 			}, nil
47 		}
48 
49@@ -1140,6 +1157,7 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
50 				User:     u.Name.Name,
51 				Channels: channels,
52 				Time:     msg.TimeOrNow(),
53+				Message:  quitmessage,
54 			}, nil
55 		}
56 	case rplMononline: