2 unstable releases

Uses old Rust 2015

0.2.0 Oct 3, 2015
0.1.0 Oct 2, 2015

#36 in #sender

MIT license

11KB
139 lines

slackbot

A higher level interface for creating Slack bots in Rust.

Crate Build Status

Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
slackbot = "*"

and this to your crate root:

extern crate slackbot;

Example

Here's a simple example to show how to make a bot that just echoes back what was said to it:

extern crate slackbot;

use slackbot::{SlackBot, Sender};

fn main() {
    let mut echo_bot = SlackBot::new("bot", "BOT_API_TOKEN");

    echo_bot.on("echo", Box::new(|sender: &mut Sender, args: &Vec<String>| {
        if args.len() > 0 {
            sender.respond_in_channel(args.join(" ")).unwrap();
        } else {
            sender.respond_in_channel("echo echo echo").unwrap();
        }
    }));

    echo_bot.run().unwrap();
}

License

slackbot is distributed under the MIT License.

Dependencies

~11–14MB
~300K SLoC