~rockorager/comlink

irc: implement /part command v1 PROPOSED

Gregory Anders: 1
 irc: implement /part command

 1 files changed, 21 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/~rockorager/comlink/patches/53989/mbox | git am -3
Learn more about email & git

[PATCH] irc: implement /part command Export this patch

/close is an alias.
---
 src/App.zig | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/App.zig b/src/App.zig
index 5d0e864..f5b22f9 100644
--- a/src/App.zig
+++ b/src/App.zig
@@ -786,7 +786,7 @@ pub fn run(self: *App) !void {
                                if (std.mem.indexOf(u8, content, msg.client.config.nick)) |_| {
                                    var buf: [64]u8 = undefined;
                                    const title_or_err = if (msg.source) |source|
                                        std.fmt.bufPrint(&buf, "{s} - {s}", .{channel.name, source })
                                        std.fmt.bufPrint(&buf, "{s} - {s}", .{ channel.name, source })
                                    else
                                        std.fmt.bufPrint(&buf, "{s}", .{channel.name});
                                    const title = title_or_err catch title: {
@@ -1272,6 +1272,8 @@ pub const Command = enum {
    quit,
    who,
    names,
    part,
    close,

    /// if we should append a space when completing
    pub fn appendSpace(self: Command) bool {
@@ -1280,6 +1282,8 @@ pub const Command = enum {
            .join,
            .me,
            .msg,
            .part,
            .close,
            => true,
            else => false,
        };
@@ -1383,6 +1387,22 @@ pub fn handleCommand(self: *App, buffer: Buffer, cmd: []const u8) !void {
            );
            return self.queueWrite(client, msg);
        },
        .part, .close => {
            if (channel == null) return error.InvalidCommand;
            var it = std.mem.tokenizeScalar(u8, cmd, ' ');

            // Skip command
            _ = it.next();

            const msg = try std.fmt.bufPrint(
                &buf,
                "PART {s}\r\n",
                .{
                    it.next() orelse channel.?.name,
                },
            );
            return self.queueWrite(client, msg);
        },
    }
}

-- 
2.45.2
Reviewed-by: Tristan Partin <tristan@partin.io>