Add /quit command
This commit is contained in:
parent
22209bd133
commit
6e982f0343
4 changed files with 34 additions and 1 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -482,6 +482,7 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced",
|
"iced",
|
||||||
"irc",
|
"irc",
|
||||||
|
"itertools",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"regex",
|
"regex",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
@ -525,6 +526,12 @@ version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "encoding"
|
name = "encoding"
|
||||||
version = "0.2.33"
|
version = "0.2.33"
|
||||||
|
@ -1248,6 +1255,15 @@ dependencies = [
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jni-sys"
|
name = "jni-sys"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|
|
@ -11,6 +11,7 @@ color-eyre = "0.6.2"
|
||||||
futures = "0.3.29"
|
futures = "0.3.29"
|
||||||
iced = { version = "0.10.0", features = ["tokio"] }
|
iced = { version = "0.10.0", features = ["tokio"] }
|
||||||
irc = "0.15.0"
|
irc = "0.15.0"
|
||||||
|
itertools = "0.12.0"
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
regex = "1.10.2"
|
regex = "1.10.2"
|
||||||
tokio = { version = "1.33.0", features = ["full"] }
|
tokio = { version = "1.33.0", features = ["full"] }
|
||||||
|
|
16
src/cri.rs
16
src/cri.rs
|
@ -10,6 +10,7 @@ use iced::{
|
||||||
use irc::proto::{
|
use irc::proto::{
|
||||||
message::Tag, CapSubCommand, Capability, ChannelExt, Command as IrcCommand, Response,
|
message::Tag, CapSubCommand, Capability, ChannelExt, Command as IrcCommand, Response,
|
||||||
};
|
};
|
||||||
|
use itertools::Itertools;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
|
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ impl Cri {
|
||||||
"/part" | "/p" => self.handle_part_command(&mut tokens),
|
"/part" | "/p" => self.handle_part_command(&mut tokens),
|
||||||
"/query" | "/q" => self.handle_query_command(&mut tokens),
|
"/query" | "/q" => self.handle_query_command(&mut tokens),
|
||||||
"/nick" | "/n" => self.handle_nick_command(&mut tokens),
|
"/nick" | "/n" => self.handle_nick_command(&mut tokens),
|
||||||
|
"/quit" => self.handle_quit_command(&mut tokens),
|
||||||
"/list" => self.handle_list_command(),
|
"/list" => self.handle_list_command(),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
@ -142,6 +144,20 @@ impl Cri {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_quit_command(&self, tokens: &mut SplitWhitespace<'_>) {
|
||||||
|
let reason: String = tokens.intersperse(" ").collect();
|
||||||
|
let reason = if reason.trim().is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(reason)
|
||||||
|
};
|
||||||
|
|
||||||
|
self.input_tx
|
||||||
|
.borrow()
|
||||||
|
.send(IrcCommand::QUIT(reason).into())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
fn on_join(
|
fn on_join(
|
||||||
&mut self,
|
&mut self,
|
||||||
chanlist: &str,
|
chanlist: &str,
|
||||||
|
|
|
@ -529,7 +529,7 @@ impl<'a> MessageLog {
|
||||||
message_id: Option<&str>,
|
message_id: Option<&str>,
|
||||||
timestamp: &DateTime<Local>,
|
timestamp: &DateTime<Local>,
|
||||||
) {
|
) {
|
||||||
let is_active = active_channel_name != Some(channel.channel_name.as_ref().unwrap());
|
let is_active = active_channel_name != channel.channel_name.as_deref();
|
||||||
if is_active {
|
if is_active {
|
||||||
channel.unread_events += 1;
|
channel.unread_events += 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue