Commit 2c123406 authored by ootoovak's avatar ootoovak Committed by Samson Ootoovak

Got Botket to echo messages.

Botket will now echo any messages written in a channel.
parent 7e050e76
......@@ -141,7 +141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -210,7 +210,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.7.17 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys-extras 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -525,7 +525,7 @@ dependencies = [
"checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
"checksum lazy_static 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4732c563b9a21a406565c4747daa7b46742f082911ae4753f390dc9ec7ee1a97"
"checksum lazy_static 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2f61b8421c7a4648c391611625d56fdd5c7567da05af1be655fd8cacc643abb3"
"checksum libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "88ee81885f9f04bff991e306fea7c1c60a5f0f9e409e99f6b40e3311a3363135"
"checksum libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cbc058951ab6a3ef35ca16462d7642c4867e6403520811f28537a4e2f2db3e71"
"checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad"
......
......@@ -17,7 +17,13 @@ impl slack::EventHandler for Botket {
raw_json: &str) {
println!("Event:");
println!("\t{:?}", event);
println!("\t{:?}", raw_json);
let ignored = "Ignored event for now.".to_string();
match event {
Ok(slack::Event::Message(slack::Message::Standard { text, .. })) => {
let _ = cli.send_message("#general", &text.unwrap());
}
_ => println!("\t{:?}", event),
}
}
fn on_ping(&mut self, cli: &mut slack::RtmClient) {
......@@ -25,11 +31,11 @@ impl slack::EventHandler for Botket {
}
fn on_close(&mut self, cli: &mut slack::RtmClient) {
println!("Close action.");
println!("--- closed");
}
fn on_connect(&mut self, cli: &mut slack::RtmClient) {
let _ = cli.send_message("#general", "I am awake.");
println!("--- connected");
}
}
......@@ -39,6 +45,12 @@ fn root(message: &str) -> String {
}
fn main() {
let rocket_handle = thread::spawn(|| {
println!("===== Starting Rocket Thread =====");
rocket::ignite().mount("/", routes![root]).launch();
"===== Done Rocket Thread ====="
});
let slack_handle = thread::spawn(|| {
println!("===== Starting Slack Client Thread =====");
let api_key = env::var("SLACK_API_KEY").unwrap();
......@@ -48,12 +60,6 @@ fn main() {
"===== Done Slack Client Thread ====="
});
let rocket_handle = thread::spawn(|| {
println!("===== Starting Rocket Thread =====");
rocket::ignite().mount("/", routes![root]).launch();
"===== Done Rocket Thread ====="
});
println!("{}", slack_handle.join().unwrap());
println!("{}", rocket_handle.join().unwrap());
println!("{}", slack_handle.join().unwrap());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment