GithubHelp home page GithubHelp logo

chatbot's Introduction

chatbot

An extensible chatbot written in rust.

Build Status

About

The construction is inspired by Hubot's extensibility. There is an ever-growing list of service adapters and message handlers as part of the project.

To get started, you might make a main function that looks like the following. Once you get that running, check out the documentation to add more packaged message handlers or write your own.

#[macro_use(handler)]
extern crate chatbot;

use chatbot::Chatbot;
use chatbot::adapter::CliAdapter;

fn main() {
    let mut bot = Chatbot::new("chatbot_name");

    let echo = handler!("EchoHandler", r"echo .+", |_, msg| {
        Some(msg.to_owned())
    });

    bot.add_handler(echo);
    bot.add_adapter(CliAdapter::new());

    bot.run();
}

Plans

Check out the issue tracker for an up-to-date list of plans for the chat bot.

Contributing

Contributions are very welcome on this project. To get started, fork the repo and clone it locally. You should be able to just do cargo run and get a working ping and github handler on the command line. If you want to run the test program using the Slack adapter, do cargo run -- --adapter slack.

chatbot's People

Contributors

caulagi avatar emk avatar jwilm avatar richo avatar smackysnacks avatar sourrust avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

chatbot's Issues

Add logging handler

The logging handler should record messages from all adapters to arbitrary back ends. Maybe it would look something like this:

let mut bot = Chatbot::new("log cutter");
bot.add_adapter(Logger::new(LoggingBackend::File("some/sort/of/path/maybe/with/file.txt"));
bot.add_adapter(Logger::new(LoggingBackend::WebHook("http://example.com/log/receiver"));
bot.add_adapter(Logger::new(LoggingBackend::PostgreSql(PostgreSqlConfig)));

Probably fine to just start with a File backend and maybe add the others in the future.

Crash in dependency

Received[84]: {"type":"presence_change","user":"U03FE5CRG","presence":"away"}
Received[85]: {"type":"presence_change","user":"U03FE5CRG","presence":"active"}
Received[86]: {"type":"presence_change","user":"U03A1010S","presence":"away"}
Received[87]: {"type":"presence_change","user":"U044FK97B","presence":"away"}
Received[88]: {"type":"presence_change","user":"U02AXSV3L","presence":"away"}
thread 'Chatbot Slack Receiver' panicked at 'unexpected error ErrorSyscall', /Users/jwilm/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.6.2/src/ssl/mod.rs:849
chatbot shutting down

Add a brain

Make it so the bot can remember things. Create a brain that the handlers and adapters can use.

  • Add a Brain trait
  • Add a RedisBrain implementation
  • maybe: Add a text file implementation

Is there any value in the text file version? It might be nice for debugging. I would worry about losing data.

Stop using rust nightlies

We're using the raw select API to handle some unknown number of ports. This is currently marked as unstable.

Relicense under dual MIT/Apache-2.0

Why?

The MIT license requires reproducing countless copies of the same copyright
header with different names in the copyright field, for every MIT library in
use. The Apache license does not have this drawback, and has protections from
patent trolls and an explicit contribution licensing clause. However, the
Apache license is incompatible with GPLv2. This is why Rust is dual-licensed as
MIT/Apache (the "primary" license being Apache, MIT only for GPLv2 compat), and
doing so would be wise for this project. This also makes this crate suitable
for inclusion in the Rust standard distribution and other project using dual
MIT/Apache.

How?

To do this, get explicit approval from each contributor of copyrightable work
(as not all contributions qualify for copyright) and then add the following to
your README:

## License

Licensed under either of
 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you shall be dual licensed as above, without any
additional terms or conditions.

and in your license headers, use the following boilerplate (based on that used in Rust):

// Copyright (c) 2015 t developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be copied, modified, or distributed except
// according to those terms.

And don't forget to update the license metadata in your Cargo.toml!

Contributor checkoff

Add rememberer

Example:

you: bot remember <thing> with id <id>
bot: got it!

Verbage needs help.

Blocked on a brain

Add PrivateMsg support for Slack

IRC has support for direct user messaging since #22. The match branch for Slack is a noop with a logger right now. Implement direct messaging for slack.

Add a GitHub issue notifier

Add support for receiving github notifications when an issue is posted. Enable filtering by repository. This requires that we can process incoming webhooks and deliver messages to the adapter (something that's not currently supported).

A way to push message to a channel outside of the handler?

Hi, Im looking at this library as a possible solution to implement my own bot, but I don't see how one can post messages outside of the handler. For example I have a thread thot polls status from some remote service and on failure posts message to the chat. Is there already api in this library that exposes this fuctionality?

Thanks!

Add a countdown handler

Create a handler where a countdown can be registered and queried. Example:

you: bot create a countdown named rust 1.0 expiring on may 15 2015
bot: got it! registered "rust 1.0" countdown for May 15, 2015.

you: bot how long until rust 1.0
bot: 10 days until rust 1.0

This is blocked on a brain and direct address filtering.

Clean up APIs for adding an adapter

An adapter can be created easily enough, but the Chatbot.add_adapter method is generic on the ChatAdapter trait. This requires putting the adapter into a Box. Right now this responsibility is on the consumer. It would be great if we could eliminate or handle that complexity behind the scenes.

Support filtered handlers

You generally don't want the bot to interject every time you say ping in a channel. Add a feature where handlers are either unfiltered or filtered by requiring the bot be addressed. For example:

Unfiltered

you: I say ping and the bot responds always
bot: pong

Filtered

you: When I say ping the bot doesn't respond.. until it's directly addressed
# silence
you: bot ping
bot: pong

Add a ping pong handler

Use the new startuppong JSON API for tracking ping pong rankings.

Commands:

  • show ()? ladder
  • show top on ladder
  • add match with winner against <other_name>

The verbage in the commands probably needs some work.

http://chatbot.rs/ DNS cannot resolve

Hi,

I wanted to check out the website, but the DNS doesn't resolve for me (in Australia). Can you check if everything is alright with the website on your end?

Can't build example program

Looks like a great project!

Building the example program on the front page from both the cargo package and from git, I get:

   Compiling statbot v0.1.0 (file:///home/emk/w/clients/faraday/statbot)
src/main.rs:6:5: 6:42 error: unresolved import `chatbot::handler::BasicMessageHandler`. There is no `BasicMessageHandler` in `chatbot::handler`
src/main.rs:6 use chatbot::handler::BasicMessageHandler;
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It might be worth putting a copy of the example program in examples/, so that Cargo automatically builds it before publishing.

bot.add_handler() only triggers when the bot is not addressed

It seems to me that any message that would trigger the bot without being addressed should still trigger the bot if it is addressed. Alternatively, there should be a third function that can add a handler for both addressed and non-addressed messages.

I'm willing to implement either option but would like to know what is the preferred course of action.

New version on crates.io

I see that the last release to crates.io was on Nov 2015, but there have been several commits after that. I was wondering if you would considering releasing a new version?

Support multiple concurrent adapters

This used to be done with ::std::sync::mpsc::Select, but that was an unstable and unsafe API. We can accomplish the same thing by simply passing a Sender<IncomingMessage> into the adapter process_events method.

openssl package conflict

error: native library openssl is being linked to by more than one version of the same pac
kage, but it can only be linked once; try updating or pinning your dependencies to ensure t
hat this package only shows up once

openssl-sys v0.6.7
openssl-sys v0.9.10

Addressed handlers do not trigger in private IRC messages

Currently addressed handlers only trigger in private messages in IRC (haven't tested Slack) if prefixed with botname: , but since the message is private I think it should already count as addressed. This might be something to wrap up in the solution to #38.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.