~emersion/goguma-dev

commands: fix kick to accept kick reasons v2 APPLIED

Eli Schwartz: 1
 commands: fix kick to accept kick reasons

 1 files changed, 4 insertions(+), 1 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/goguma-dev/patches/51771/mbox | git am -3
Learn more about email & git

[PATCH v2] commands: fix kick to accept kick reasons Export this patch

Given the kick message:

```
/kick user123 testing, testing, see if kick messages work
```

The IRC message passed the nick field as:

"user123 testing, testing, see if kick messages work"

which simply did not work at all. Instead, pass only the first word as
the nick, and as a bonus, pass the rest concatenated as the kick reason.

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---

v2: kick reason is an unpackable list. This allows passing zero
arguments over the wire:

```
KICK #channel user123
```

instead of an empty one:

```
KICK #channel user123 :
```

In practice it may not make a difference. /quote KICK #channel user123 :
will, on e.g. libera, message back as KICK #channel user123 user123,
giving the kick reason as the kicked user's nick. So does not sending an
argument over the wire! But it's "cleaner" so do it anyway.

 lib/commands.dart | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/commands.dart b/lib/commands.dart
index e42eef7..ad46bd9 100644
--- a/lib/commands.dart
+++ b/lib/commands.dart
@@ -32,7 +32,10 @@ String? _kick(BuildContext context, String? param) {
	if (!client.isChannel(buffer.name)) {
		throw CommandException('This command can only be used in channels');
	}
	client.send(IrcMessage('KICK', [buffer.name, _requireParam(param)]));
	var parts = _requireParam(param).split(' ');
	var nick = parts[0];
	var reason = parts.length > 1? [parts.sublist(1).join(' ')] : <String>[];
	client.send(IrcMessage('KICK', [buffer.name, nick, ...reason]));
	return null;
}

-- 
2.43.2
Yeah, some IRC servers fill out a "default reason" when the client doesn't
provide one. I wouldn't expect all servers to do so though.

In any case, this version looks good. Pushed, thanks!