~taiite/public-inbox

senpai: Automatically join channels on start v2 APPLIED

delthas: 1
 Automatically join channels on start

 4 files changed, 20 insertions(+), 8 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~taiite/public-inbox/patches/23818/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH senpai v2] Automatically join channels on start Export this patch

Supporting channels with keys and merging JOINs in a single message is
TODO for later. :)
---
 app.go           |  5 +++++
 config.go        |  3 ++-
 doc/senpai.5.scd |  5 +++++
 irc/session.go   | 15 ++++++++-------
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/app.go b/app.go
index 57c12de..3b8e3ad 100644
--- a/app.go
+++ b/app.go
@@ -464,6 +464,11 @@ func (app *App) handleIRCEvent(ev interface{}) {
	// Mutate UI state
	switch ev := ev.(type) {
	case irc.RegisteredEvent:
		for _, channel := range app.cfg.Channels {
			// TODO: group JOIN messages
			// TODO: support autojoining channels with keys
			app.s.Join(channel, "")
		}
		body := new(ui.StyledStringBuilder)
		body.WriteString("Connected to the server")
		if app.s.Nick() != app.cfg.Nick {
diff --git a/config.go b/config.go
index b744ba8..10656f4 100644
--- a/config.go
+++ b/config.go
@@ -4,8 +4,8 @@ import (
	"errors"
	"fmt"
	"io/ioutil"
	"strings"
	"strconv"
	"strings"

	"github.com/gdamore/tcell/v2"

@@ -53,6 +53,7 @@ type Config struct {
	User     string
	Password *string
	NoTLS    bool `yaml:"no-tls"`
	Channels []string

	NoTypings bool `yaml:"no-typings"`
	Mouse     *bool
diff --git a/doc/senpai.5.scd b/doc/senpai.5.scd
index 66a2ccd..b3edd18 100644
--- a/doc/senpai.5.scd
+++ b/doc/senpai.5.scd
@@ -33,6 +33,10 @@ Some settings are required, the others are optional.
*password*
	Your password, used for SASL authentication.

*channels*
	A list of channel names that senpai will automatically join at startup and
	server reconnect.

*highlights*
	A list of keywords that will trigger a notification and a display indicator
	when said by others.  By default, senpai will use your current nickname.
@@ -127,6 +131,7 @@ nick: Guest123456
user: senpai
real: Guest von Lenon
password: A secure password, I guess?
channels: ["#rahxephon"]
highlights:
	- guest
	- senpai
diff --git a/irc/session.go b/irc/session.go
index e50312f..18a2c6b 100644
--- a/irc/session.go
+++ b/irc/session.go
@@ -104,13 +104,14 @@ type Session struct {
	typings      *Typings             // incoming typing notifications.
	typingStamps map[string]time.Time // user typing instants.

	nick   string
	nickCf string // casemapped nickname.
	user   string
	real   string
	acct   string
	host   string
	auth   SASLClient
	nick     string
	nickCf   string // casemapped nickname.
	user     string
	real     string
	acct     string
	host     string
	auth     SASLClient
	autojoin map[string]string

	availableCaps map[string]string
	enabledCaps   map[string]struct{}
-- 
2.30.0
This patch doesn't work well with the previous one that makes /join
switch to the new buffer...  Maybe irc.Session.pendingChannels should
be moved into App?

Also irc.Session.autojoin is unused.

On Tue, 13 Jul 2021 19:30:30 +0200, delthas wrote:
Ok, since it seems to be intended behavior (e.g. hexchat also switches
to channels on join), I'll merge this.

Just removed unused "autojoin" variable.