aboutsummaryrefslogtreecommitdiff
path: root/src/feature/jisoku.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/feature/jisoku.rs')
-rw-r--r--src/feature/jisoku.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/feature/jisoku.rs b/src/feature/jisoku.rs
new file mode 100644
index 0000000..70bc886
--- /dev/null
+++ b/src/feature/jisoku.rs
@@ -0,0 +1,55 @@
1extern crate telegram_bot;
2use telegram_bot::{Api, Message, MessageType};
3use std::sync::{Arc, Mutex};
4use std::thread;
5use std::time::Duration;
6
7use std::ascii::AsciiExt;
8
9use feature::FeatureResult;
10use feature::Feature;
11
12pub struct Jisoku {
13 running: bool,
14}
15
16const MESSAGES: [&'static str; 5] = ["JISOKU METER FURIKIRI UBAU GAME",
17 "I AM A CHASER DARE YORI HAYAI RACE",
18 "LIFE IS FIRE TSUKIRU MADE HIGH PACE",
19 "LETS GET READY TO RUMBLE MEZAMERO PASSION",
20 "*insert dubstep*"];
21
22impl Feature for Jisoku {
23 fn name(&self) -> &'static str {
24 "Jisoku Meter"
25 }
26 fn init(&mut self) {}
27 fn handle(&mut self, a: Api, m: Message) -> Result<FeatureResult, String> {
28 if let MessageType::Text(ref s) = m.msg {
29 if !(&s).contains("JISOKU METER") {
30 return Ok(FeatureResult::Skip);
31 }
32 } else {
33 return Ok(FeatureResult::Skip);
34 }
35
36 if self.running {
37 return Ok(FeatureResult::Skip);
38 }
39 self.running = true;
40 thread::spawn(move || {
41 for s in MESSAGES.into_iter() {
42 a.send_message(m.chat.id(), (*s).to_owned(), None, None, None, None);
43 thread::sleep(Duration::new(1, 0));
44 }
45 });
46 Ok(FeatureResult::Handled)
47 }
48}
49
50impl Jisoku {
51 pub fn new() -> Jisoku {
52 let mut j = Jisoku { running: false };
53 j
54 }
55}