~delthas/senpai-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH senpai] config: add user specified disabled-error list

Details
Message ID
<20220605130331.15878-1-tim@timculverhouse.com>
DKIM signature
pass
Download raw message
Patch: +28 -6
Allow users to specify additional disabled (blacklisted) errors via a
config option. These will be added to the default list of disabled
errors.
---
 app.go           | 19 ++++++++++++++-----
 config.go        |  7 ++++++-
 doc/senpai.5.scd |  8 ++++++++
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/app.go b/app.go
index 9f86b99..27e89f5 100644
--- a/app.go
+++ b/app.go
@@ -923,7 +923,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
			go app.ircLoop(ev.ID)
		}
	case irc.ErrorEvent:
		if isBlackListed(msg.Command) {
		if app.isBlackListed(msg.Command) {
			break
		}
		var head string
@@ -949,11 +949,20 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
	}
}

func isBlackListed(command string) bool {
	switch command {
	case "002", "003", "004", "422":
func (app *App) isBlackListed(command string) bool {
	blacklist := []string{
		// useless connection messages
		return true
		"002",
		"003",
		"004",
		"422",
	}
	// user specified blacklist
	blacklist = append(blacklist, app.cfg.DisabledErrors...)
	for _, item := range blacklist {
		if command == item {
			return true
		}
	}
	return false
}
diff --git a/config.go b/config.go
index 5ac2a8a..51d21e5 100644
--- a/config.go
+++ b/config.go
@@ -72,6 +72,8 @@ type Config struct {
	Colors ConfigColors

	Debug bool

	DisabledErrors []string
}

func DefaultHighlightPath() (string, error) {
@@ -104,7 +106,8 @@ func Defaults() (cfg Config, err error) {
			Prompt: tcell.ColorDefault,
			Unread: tcell.ColorDefault,
		},
		Debug: false,
		Debug:          false,
		DisabledErrors: nil,
	}

	return
@@ -301,6 +304,8 @@ func unmarshal(filename string, cfg *Config) (err error) {
			if cfg.Debug, err = strconv.ParseBool(debug); err != nil {
				return err
			}
		case "disabled-errors":
			cfg.DisabledErrors = append(cfg.DisabledErrors, d.Params...)
		default:
			return fmt.Errorf("unknown directive %q", d.Name)
		}
diff --git a/doc/senpai.5.scd b/doc/senpai.5.scd
index ec6bea5..9264fcb 100644
--- a/doc/senpai.5.scd
+++ b/doc/senpai.5.scd
@@ -157,6 +157,14 @@ colors {
|  unread
:  foreground color for unread buffer names in buffer lists

*disabled-errors*
	A space separated list of error codes that will be ignored. Add the three
	digit code, with any leading zeroes, to this list to disable the message.
	Codes specified will be added to the default list. This directive can be
	specified multiple times

	Default: 002, 003, 004, 422

*debug*
	Dump all sent and received data to the home buffer, useful for debugging.
	Defaults to false.
-- 
2.36.1
Details
Message ID
<2fde4bdf47cf96b94625de0e08e3acc4@dille.cc>
In-Reply-To
<20220605130331.15878-1-tim@timculverhouse.com> (view parent)
DKIM signature
pass
Download raw message
> Allow users to specify additional disabled (blacklisted) errors via a
> config option. These will be added to the default list of disabled
> errors.

Nice patch. What's your use case? Which errors would you like to see 
blacklisted?
Details
Message ID
<CKJBAZ1M37E9.28ZGIROPYLOAH@TimBook-Arch>
In-Reply-To
<2fde4bdf47cf96b94625de0e08e3acc4@dille.cc> (view parent)
DKIM signature
pass
Download raw message
On Mon Jun 6, 2022 at 2:16 PM CDT, delthas wrote:
> Nice patch. What's your use case? Which errors would you like to see 
> blacklisted?

Specifically, I am blacklisting 263. Every time I opened senpai, I would
get 4-5 263 WHO is rate limited messages. I started to dig into *why* I
was getting those (senpai, soju, libera, ??) but figured blacklisting
additional errors would be a nice thing to have. Hence, patch. A bit of
a bandaid, admittedly.

Tim
Reply to thread Export thread (mbox)