Automatically join a stored channel on INVITE v1 PROPOSED

delthas: 1
 Automatically join a stored channel on INVITE

 1 files changed, 12 insertions(+), 0 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/~emersion/soju-dev/patches/43420/mbox | git am -3
Learn more about email & git

[PATCH] Automatically join a stored channel on INVITE Export this patch

Some channels are typically protected with a legacy bot to which
a message is sent, causing the bot to send an INVITE to a channel,
which is invite-only.

Previously, a connect-command for sending a custom message to the
bot could be added, but there was no way to automatically accept
the invite.

This commit enables soju to automatically join a previously saved
channel when we receive an invite to it.

- Joining #restricted, then getting disconnected from the upstream,
  sending a message to the bot, receiving an invite and accepting it
- Joining #watercooler, getting kicked, then invited again after a

We eat the INVITE event so that we just transparently join the
channel without warning all downstreams.

Of course, of note is that we do *not* accept invites of
unknown/unsaved channels.

Thanks to eju for finding the issue and providing a first patch.
 upstream.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/upstream.go b/upstream.go
index c26f993..38ecc26 100644
--- a/upstream.go
+++ b/upstream.go
@@ -1587,6 +1587,18 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err

		weAreInvited := uc.isOurNick(nick)

		if weAreInvited {
			joined := uc.channels.Get(channel) != nil
			c := uc.network.channels.Get(channel)
			if !joined && c != nil {
				// Automatically join a saved channel when we are invited
				for _, msg := range xirc.GenerateJoin([]string{c.Name}, []string{c.Key}) {
					uc.SendMessage(ctx, msg)

		uc.forEachDownstream(func(dc *downstreamConn) {
			if !weAreInvited && !dc.caps.IsEnabled("invite-notify") {

base-commit: 97cfb366b03d0ebf40ce9a2eee3f11441a883832