From 022b4af86c3e4656677a232e486f51e2cd4ca94c Mon Sep 17 00:00:00 2001 From: angelsl Date: Sun, 7 Feb 2016 16:01:05 +0800 Subject: [PATCH] Fix Message::source_nickname --- src/client/data/message.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/client/data/message.rs b/src/client/data/message.rs index 4415424..452138e 100644 --- a/src/client/data/message.rs +++ b/src/client/data/message.rs @@ -34,12 +34,14 @@ impl Message { /// Gets the nickname of the message source, if it exists. pub fn source_nickname(&self) -> Option<&str> { + // ::= | [ '!' ] [ '@' ] + // ::= self.prefix.as_ref().and_then(|s| match (s.find('!'), s.find('@'), s.find('.')) { - (_, _, Some(_)) => None, - (Some(i), _, None) => Some(&s[..i]), - (None, Some(i), None) => Some(&s[..i]), - (None, None, None) => Some(&s) + (Some(i), _, _) => Some(&s[..i]), // nick!user + (None, Some(i), _) => Some(&s[..i]), // nick@host + (None, None, None) => Some(&s), // nick + _ => None // server.name } ) }