From 41e1b7bc8279cfe47577a9191a738325950bb431 Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 7 Apr 2016 18:22:08 +0200 Subject: bare feature hinzugefuegt diff --git a/src/feature/bare.rs b/src/feature/bare.rs new file mode 100644 index 0000000..ef5caaf --- /dev/null +++ b/src/feature/bare.rs @@ -0,0 +1,34 @@ +extern crate telegram_bot; +use telegram_bot::{Api, Message, MessageType}; +use std::ascii::AsciiExt; + +use feature::FeatureResult; +use feature::Feature; + +pub struct BareFeature { + penis: i32, +} + +impl Feature for BareFeature { + fn name(&self) -> &'static str { + "BareFeature" + } + fn init(&mut self) {} + fn handle(&mut self, a: Api, m: Message) -> Result { + if let MessageType::Text(ref s) = m.msg { + if !(&s).to_ascii_lowercase().contains("luggas") { + return Ok(FeatureResult::Skip); + } + } else { + return Ok(FeatureResult::Skip); + } + + Ok(FeatureResult::Skip) + } +} + +impl BareFeature { + pub fn new() -> BareFeature { + BareFeature { penis: 1 } + } +} diff --git a/src/feature/topanime.rs b/src/feature/topanime.rs index cccc976..94edd30 100644 --- a/src/feature/topanime.rs +++ b/src/feature/topanime.rs @@ -30,12 +30,12 @@ impl Anime { pub struct TopAnime { animes: Vec, - last_access: f64, + last_update: f64, } impl Feature for TopAnime { fn name(&self) -> &'static str { - "Tasterank" + "TopAnime" } fn init(&mut self) {} fn handle(&mut self, a: Api, m: Message) -> Result { @@ -95,14 +95,14 @@ impl TopAnime { pub fn new() -> TopAnime { let mut t = TopAnime { animes: vec![], - last_access: 0f64, + last_update: 0f64, }; t.init(); t } fn update_animes(&mut self) -> Result<(), io::Error> { let now = time::precise_time_s(); - if now - self.last_access < 3600.0f64 { + if now - self.last_update < 3600.0f64 { return Ok(()); } let mut f = try!(File::open("data/animescore.json")); @@ -113,7 +113,7 @@ impl TopAnime { Err(e) => return Err(io::Error::new(io::ErrorKind::InvalidData, format!("{}", e))), }; self.animes = v; - self.last_access = now; + self.last_update = now; Ok(()) } } -- cgit v0.10.1