From 8065fdd8ff96c5c5256d2fa0e37aac7e68c84f6a Mon Sep 17 00:00:00 2001 From: Sijmen Date: Fri, 17 Nov 2023 10:17:32 +0100 Subject: [PATCH] Allow specifying a reason when parting --- src/main.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index cf44a8d..0177c49 100644 --- a/src/main.rs +++ b/src/main.rs @@ -123,17 +123,17 @@ impl Cri { return; } - self - .input_tx - .borrow() - .send( - IrcCommand::PART( - channel, - tokens.next().map(str::to_string), - ) - .into(), - ) - .unwrap(); + let reason = tokens.collect::>().join(" "); + let reason = if reason.is_empty() { + None + } else { + Some(reason) + }; + + self.input_tx + .borrow() + .send(IrcCommand::PART(channel, reason).into()) + .unwrap(); } "/query" => self .message_log @@ -190,7 +190,7 @@ impl Application for Cri { .on_quit(&source_nickname, comment.as_deref()); } - IrcCommand::PRIVMSG(msgtarget, content) => { + IrcCommand::PRIVMSG(msgtarget, content) | IrcCommand::NOTICE(msgtarget, content) => { let channel = message.response_target().unwrap_or(msgtarget).to_string(); self.message_log .on_privmsg(&channel, &source_nickname, content);