Allow specifying a reason when parting

This commit is contained in:
Sijmen 2023-11-17 10:17:32 +01:00
parent 302ac9b050
commit 8065fdd8ff
Signed by: vijfhoek
GPG key ID: DAF7821E067D9C48

View file

@ -123,17 +123,17 @@ impl Cri {
return; return;
} }
self let reason = tokens.collect::<Vec<_>>().join(" ");
.input_tx let reason = if reason.is_empty() {
.borrow() None
.send( } else {
IrcCommand::PART( Some(reason)
channel, };
tokens.next().map(str::to_string),
) self.input_tx
.into(), .borrow()
) .send(IrcCommand::PART(channel, reason).into())
.unwrap(); .unwrap();
} }
"/query" => self "/query" => self
.message_log .message_log
@ -190,7 +190,7 @@ impl Application for Cri {
.on_quit(&source_nickname, comment.as_deref()); .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(); let channel = message.response_target().unwrap_or(msgtarget).to_string();
self.message_log self.message_log
.on_privmsg(&channel, &source_nickname, content); .on_privmsg(&channel, &source_nickname, content);