commodore 0.1.0

Slack Command API handler library
docs.rs failed to build commodore-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: commodore-0.3.0

commodore

Build Status Coverage Status Software License

call rank and take command of slack with rust at your helm

Commodore allows you to easily extend your Slack experience with Rust via Slack's Command API.

rust docs

Find them here

usage

#[macro_use]
extern crate log;
extern crate env_logger;

extern crate commodore;
extern crate hyper;

use commodore::{Captures, Command, Mux, Response, Responder};
use hyper::Server;
use std::thread;
use std::time::Duration;

pub fn main() {
    env_logger::init().unwrap();
    let addr = format!("0.0.0.0:{}", 4567);
    let mut mux = Mux::new();
    mux.command("/commodore",
                "secrettoken",
                |c: &Command, _: &Option<Captures>, responder: Box<Responder>| -> Option<Response> {
                    info!("handler recv cmd {:#?}", c);
                    thread::spawn(move || {
                        // simulate doing something time consuming
                        thread::sleep(Duration::from_secs(3));
                        responder.respond(Response::in_channel("some time later"));
                    });
                    Some(Response::emphemeral("I'll get back to you"))
                });
    let srvc = Server::http(&addr[..])
                   .unwrap()
                   .handle(mux);
    println!("listening on {}", addr);
    srvc.unwrap();
}

Doug Tangren (softprops) 2016