[PATCH 1/2] Optionally show quit and part messages
Export this patch
These are not 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.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
---
app.go | 12 +++++++++++ -
config.go | 11 +++++++++++
irc/events.go | 2 ++
irc/session.go | 16 ++++++++++++++ --
4 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/app.go b/app.go
index 24546e7..61a7401 100644
--- a/app.go
+++ b/app.go
@@ -1639,6 +1639,11 @@ func (app *App) formatEvent(ev irc.Event) ui.Line {
Foreground: app.cfg.Colors.Status,
})
body.WriteString(ev.User)
+ if app.cfg.QuitMessages {
+ body.WriteString(" (")
+ body.WriteString(ev.Message)
+ body.WriteByte(')')
+ }
return ui.Line{
At: ev.Time,
Head: "--",
@@ -1654,11 +1659,16 @@ func (app *App) formatEvent(ev irc.Event) ui.Line {
body.SetStyle(vaxis.Style{
Foreground: ui.ColorRed,
})
- body.WriteByte('-')
+ body.WriteByte('x')
body.SetStyle(vaxis.Style{
Foreground: app.cfg.Colors.Status,
})
body.WriteString(ev.User)
+ if app.cfg.QuitMessages {
+ body.WriteString(" (")
+ body.WriteString(ev.Message)
+ body.WriteByte(')')
+ }
return ui.Line{
At: ev.Time,
Head: "--",
diff --git a/config.go b/config.go
index 3b6c40b..69cee97 100644
--- a/config.go
+++ b/config.go
@@ -108,6 +108,7 @@ type Config struct {
ChanColEnabled bool
MemberColWidth int
MemberColEnabled bool
+ QuitMessages bool
TextMaxWidth int
StatusEnabled bool
@@ -146,6 +147,7 @@ func Defaults() Config {
ChanColEnabled: true,
MemberColWidth: 16,
MemberColEnabled: true,
+ QuitMessages: false,
TextMaxWidth: 0,
StatusEnabled: true,
Colors: ui.ConfigColors{
@@ -425,6 +427,15 @@ func unmarshal(filename string, cfg *Config) (err error) {
return fmt.Errorf("unknown colors directive %q", child.Name)
}
}
+ case "quitmessages":
+ var quitmessages string
+ if err := d.ParseParams(&quitmessages); err != nil {
+ return err
+ }
+
+ if cfg.QuitMessages, err = strconv.ParseBool(quitmessages); err != nil {
+ return err
+ }
case "debug":
var debug string
if err := d.ParseParams(&debug); err != nil {
diff --git a/irc/events.go b/irc/events.go
index 9bb61ba..716a9c1 100644
--- a/irc/events.go
+++ b/irc/events.go
@@ -48,12 +48,14 @@ type UserPartEvent struct {
User string
Channel string
Time time.Time
+ Message string
}
type UserQuitEvent struct {
User string
Channels []string
Time time.Time
+ Message string
}
type UserOnlineEvent struct {
diff --git a/irc/session.go b/irc/session.go
index 9132e65..0101171 100644
--- a/irc/session.go
+++ b/irc/session.go
@@ -901,8 +901,11 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
}
var channel string
- if err := msg.ParseParams(&channel); err != nil {
- return nil, err
+ var partmessage string
+ if len(msg.Params) < 2 {
+ if err := msg.ParseParams(&channel, &partmessage); err != nil {
+ return nil, err
+ }
}
if playback {
@@ -910,6 +913,7 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
User: msg.Prefix.Name,
Channel: channel,
Time: msg.TimeOrNow(),
+ Message: partmessage,
}, nil
}
@@ -982,10 +986,17 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
return nil, errMissingPrefix
}
+ var quitmessage string
+
+ if err := msg.ParseParams(&quitmessage); err != nil {
+ return nil, err
+ }
+
if playback {
return UserQuitEvent{
User: msg.Prefix.Name,
Time: msg.TimeOrNow(),
+ Message: quitmessage,
}, nil
}
@@ -1006,6 +1017,7 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
User: u.Name.Name,
Channels: channels,
Time: msg.TimeOrNow(),
+ Message: quitmessage,
}, nil
}
case rplMononline:
--
2.45.1
[PATCH 2/2] doc/senpai.5.scd: document "quitmessages" option
Export this patch
See previous commit.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
---
doc/senpai.5.scd | 3 +++
1 file changed, 3 insertions(+)
diff --git a/doc/senpai.5.scd b/doc/senpai.5.scd
index b6a29f9..17331e3 100644
--- a/doc/senpai.5.scd
+++ b/doc/senpai.5.scd
@@ -153,6 +153,9 @@ pane-widths {
*mouse*
Enable or disable mouse support. Defaults to true.
+ *quitmessages*
+ Enable or disable showing quit and part messages. Defaults to false.
+
*colors* { ... }
Settings for colors of different UI elements.
--
2.45.1