aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Hoeppner2015-04-18 16:18:33 +0200
committerTill Hoeppner2015-04-18 16:18:33 +0200
commit984d479f2c1686c1bcfac44a2d0f23f8ba010b1b (patch)
tree4fb02ff7bb496348aadbf469dd61e331a906b962
parentb9bd227b0e9902af869cb4b4dd1f5834cc462886 (diff)
downloadirsc-984d479f2c1686c1bcfac44a2d0f23f8ba010b1b.tar.gz
irsc-984d479f2c1686c1bcfac44a2d0f23f8ba010b1b.tar.xz
irsc-984d479f2c1686c1bcfac44a2d0f23f8ba010b1b.zip
Fix CTCP recognition/make tests pass
-rw-r--r--src/message.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/message.rs b/src/message.rs
index 25e176c..50baaaf 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -41,8 +41,6 @@ impl<'a> FromStr for Message<'a> {
let len = i.len();
let mut s = i;
- let msg_type = if s.chars().next() == Some('\u{1}') { MsgType::Ctcp } else { MsgType::Irc };
-
let prefix = if len >= 1 && s.chars().next() == Some(':') {
s.find(' ').map(|i| {
let p = s.slice_chars(1, i).to_owned();
@@ -75,6 +73,9 @@ impl<'a> FromStr for Message<'a> {
if s.chars().next() == Some(' ') { s = &s[1..] };
}
+ let msg_type = if suffix.as_ref()
+ .and_then(|s| s.chars().next()) == Some('\u{1}') { MsgType::Ctcp } else { MsgType::Irc };
+
command.map(move |c|
Ok(Message::new(prefix.map(|p| Cow::Owned(p)),
c.unwrap(),