aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorTill Höppner2016-01-23 23:32:54 +0100
committerTill Höppner2016-01-23 23:32:54 +0100
commit17af9b65cc75ddc15091d1f3a4365c13336cceb7 (patch)
tree0f30d946cf3214647f3896f9fe4dc07b8b05dba6 /src/event.rs
parentee96e7d79ef9e5505a2b7440cd5dc544da23540d (diff)
downloadilc-17af9b65cc75ddc15091d1f3a4365c13336cceb7.tar.gz
ilc-17af9b65cc75ddc15091d1f3a4365c13336cceb7.tar.xz
ilc-17af9b65cc75ddc15091d1f3a4365c13336cceb7.zip
Add seen command
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs
index 83bb876..f497359 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -150,6 +150,26 @@ pub enum Type<'a> {
}
}
+impl<'a> Type<'a> {
+ pub fn involves(&self, needle: &str) -> bool {
+ use self::Type::*;
+ match self {
+ &Msg { ref from, .. } => from == needle,
+ &Action { ref from, .. } => from == needle,
+ &Join { ref nick, .. } => nick == needle,
+ &Part { ref nick, .. } => nick == needle,
+ &Quit { ref nick, .. } => nick == needle,
+ &Nick { ref old_nick, ref new_nick, .. } => old_nick == needle || new_nick == needle,
+ &Notice { ref from, .. } => from == needle,
+ &Kick { ref kicked_nick, ref kicking_nick, .. } => *kicked_nick == Cow::Borrowed(needle)
+ || kicking_nick.as_ref().map_or(false, |k| k.as_ref() == Cow::Borrowed(needle)),
+ &TopicChange { ref nick, .. } => nick.as_ref().map_or(false, |k| k.as_ref() == needle),
+ &Mode { ref nick, .. } => nick.as_ref().map_or(false, |k| k.as_ref() == Cow::Borrowed(needle)),
+ _ => false
+ }
+ }
+}
+
#[derive(Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct NoTimeHash<'a>(pub Event<'a>);