an experimental irc client

Fix part command for dms

authored by

Palanix and committed by rockorager.dev 96a069cd 995e83f6

verified
+18 -8
+18 -8
src/app.zig
··· 940 940 941 941 // Skip command 942 942 _ = it.next(); 943 + const target = it.next() orelse channel.?.name; 943 944 944 - const msg = try std.fmt.bufPrint( 945 - &buf, 946 - "PART {s}\r\n", 947 - .{ 948 - it.next() orelse channel.?.name, 949 - }, 950 - ); 951 - return client.queueWrite(msg); 945 + if (target[0] != '#') { 946 + for (client.channels.items, 0..) |search, i| { 947 + if (!mem.eql(u8, search.name, target)) continue; 948 + var chan = client.channels.orderedRemove(i); 949 + chan.deinit(self.alloc); 950 + break; 951 + } 952 + } else { 953 + const msg = try std.fmt.bufPrint( 954 + &buf, 955 + "PART {s}\r\n", 956 + .{ 957 + target, 958 + }, 959 + ); 960 + return client.queueWrite(msg); 961 + } 952 962 }, 953 963 .redraw => self.vx.queueRefresh(), 954 964 .version => {