Compare commits
2 commits
ef4c554820
...
8065fdd8ff
Author | SHA1 | Date | |
---|---|---|---|
8065fdd8ff | |||
302ac9b050 |
1 changed files with 28 additions and 20 deletions
48
src/main.rs
48
src/main.rs
|
@ -82,7 +82,10 @@ impl Cri {
|
|||
let command = tokens.next().unwrap();
|
||||
match command {
|
||||
"/join" => {
|
||||
let channel = tokens.next().map(str::to_string).or_else(|| self.message_log.active_channel.clone());
|
||||
let channel = tokens
|
||||
.next()
|
||||
.map(str::to_string)
|
||||
.or_else(|| self.message_log.active_channel.clone());
|
||||
if channel.is_none() {
|
||||
// TODO error message
|
||||
return;
|
||||
|
@ -94,16 +97,21 @@ impl Cri {
|
|||
return;
|
||||
}
|
||||
|
||||
self
|
||||
.input_tx
|
||||
.borrow()
|
||||
.send(IrcCommand::JOIN(channel.clone(), tokens.next().map(str::to_string), None).into())
|
||||
.unwrap();
|
||||
self.input_tx
|
||||
.borrow()
|
||||
.send(
|
||||
IrcCommand::JOIN(channel.clone(), tokens.next().map(str::to_string), None)
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
self.message_log.set_active(Some(channel));
|
||||
},
|
||||
}
|
||||
"/part" => {
|
||||
let channel = tokens.next().map(str::to_string).or_else(|| self.message_log.active_channel.clone());
|
||||
let channel = tokens
|
||||
.next()
|
||||
.map(str::to_string)
|
||||
.or_else(|| self.message_log.active_channel.clone());
|
||||
if channel.is_none() {
|
||||
// TODO error message
|
||||
return;
|
||||
|
@ -115,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::<Vec<_>>().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
|
||||
|
@ -182,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);
|
||||
|
|
Loading…
Reference in a new issue