aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/feature/bare.rs34
-rw-r--r--src/feature/topanime.rs10
2 files changed, 39 insertions, 5 deletions
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 @@
1extern crate telegram_bot;
2use telegram_bot::{Api, Message, MessageType};
3use std::ascii::AsciiExt;
4
5use feature::FeatureResult;
6use feature::Feature;
7
8pub struct BareFeature {
9 penis: i32,
10}
11
12impl Feature for BareFeature {
13 fn name(&self) -> &'static str {
14 "BareFeature"
15 }
16 fn init(&mut self) {}
17 fn handle(&mut self, a: Api, m: Message) -> Result<FeatureResult, String> {
18 if let MessageType::Text(ref s) = m.msg {
19 if !(&s).to_ascii_lowercase().contains("luggas") {
20 return Ok(FeatureResult::Skip);
21 }
22 } else {
23 return Ok(FeatureResult::Skip);
24 }
25
26 Ok(FeatureResult::Skip)
27 }
28}
29
30impl BareFeature {
31 pub fn new() -> BareFeature {
32 BareFeature { penis: 1 }
33 }
34}
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 {
30 30
31pub struct TopAnime { 31pub struct TopAnime {
32 animes: Vec<Anime>, 32 animes: Vec<Anime>,
33 last_access: f64, 33 last_update: f64,
34} 34}
35 35
36impl Feature for TopAnime { 36impl Feature for TopAnime {
37 fn name(&self) -> &'static str { 37 fn name(&self) -> &'static str {
38 "Tasterank" 38 "TopAnime"
39 } 39 }
40 fn init(&mut self) {} 40 fn init(&mut self) {}
41 fn handle(&mut self, a: Api, m: Message) -> Result<FeatureResult, String> { 41 fn handle(&mut self, a: Api, m: Message) -> Result<FeatureResult, String> {
@@ -95,14 +95,14 @@ impl TopAnime {
95 pub fn new() -> TopAnime { 95 pub fn new() -> TopAnime {
96 let mut t = TopAnime { 96 let mut t = TopAnime {
97 animes: vec![], 97 animes: vec![],
98 last_access: 0f64, 98 last_update: 0f64,
99 }; 99 };
100 t.init(); 100 t.init();
101 t 101 t
102 } 102 }
103 fn update_animes(&mut self) -> Result<(), io::Error> { 103 fn update_animes(&mut self) -> Result<(), io::Error> {
104 let now = time::precise_time_s(); 104 let now = time::precise_time_s();
105 if now - self.last_access < 3600.0f64 { 105 if now - self.last_update < 3600.0f64 {
106 return Ok(()); 106 return Ok(());
107 } 107 }
108 let mut f = try!(File::open("data/animescore.json")); 108 let mut f = try!(File::open("data/animescore.json"));
@@ -113,7 +113,7 @@ impl TopAnime {
113 Err(e) => return Err(io::Error::new(io::ErrorKind::InvalidData, format!("{}", e))), 113 Err(e) => return Err(io::Error::new(io::ErrorKind::InvalidData, format!("{}", e))),
114 }; 114 };
115 self.animes = v; 115 self.animes = v;
116 self.last_access = now; 116 self.last_update = now;
117 Ok(()) 117 Ok(())
118 } 118 }
119} 119}