Giter Club home page Giter Club logo

butler's Introduction

Butler

Butler is an extendable, chat robot designed to make your life easier. He's a swell guy.

Butler's full documentation is available online

Creating your own Butler

You can install the butler archive with this command:

$ mix archive.install https://github.com/butlerbot/butler/releases/download/v0.7.1/butler_new-0.7.1.ez

Once you've done that you can generate your robot. For instance, if you want to name your robot marvin then you would run:

$ mix butler.new marvin
$ cd marvin
$ mix deps.get
$ mix run --no-halt

Congratulations! You now have your own butler.

Butler comes with a default configuration, which can be updated in config/config.exs or config/ENV.exs per environment.

Plugins - Hello World

Butler's abilities come from plugins:

defmodule MyPlugin do
  use Butler.Plugin

  @usage """
  #{name} test <phrase> - Lets the user know that they got the message
  """
  respond(~r/test (.*)$/, [_all, phrase], conn) do
    reply conn, "I heard #{phrase}"
  end

  @usage """
  lambda - expresses a love for lambdas to the channel
  """
  hear(~r/lambda/, conn) do
    say conn, "lambda all the things"
  end
end

You can include these plugins inside any butler project by updating your config like so:

config :butler,
  name: ...,
  adapter: ...,
  plugins: [
    {Butler.Plugins.Help, []},
    {MyPlugin, []}
  ]

There are other plugins available on hex that can be easily included into your bot.

Adapters

Butler has adapters in order to talk to multiple chat platforms. The default platform is Slack and an adapter is provided as a part of Butler.

For local development there is a terminal adapter which provides a lightweight repl interface.

Slack Adapter

Butler needs a slack api token in order to connect to your organization.

$ export BUTLER_SLACK_API_KEY=your_api_key

You can then run butler in production mode.

$ MIX_ENV=prod mix compile
$ MIX_ENV=prod mix run --no-halt

Deploying to Heroku

Heroku is the easiest way to deploy your bot:

First you'll need to create a new application with the elixir buildpack:

$ heroku create --buildpack "https://github.com/HashNuke/heroku-buildpack-elixir.git"

Or if you've already created your application you can set the buildpack directly:

$ heroku config:set BUILDPACK_URL="https://github.com/HashNuke/heroku-buildpack-elixir.git"

Before you deploy you need to set any environment variables that you'll need. For the slack adapter that will be this:

$ heroku config:set BUTLER_SLACK_API_KEY=your-api-key

You'll also have to make sure that any variables you need at compile time are included in the elixir_buildpack.config file:

$ cat elixir_buildpack.config
erlang_version=17.5
elixir_version=1.1.1
always_rebuild=true
config_vars_to_export=(BUTLER_SLACK_API_KEY BUTLER_SLACK_API_KEY)

If these config vars aren't included in the config_vars_to_export then they won't be availble during compile time which will cause issues during runtime.

For more information on configuration you can check out the elixir_buildpack.

Once the configuration variables have been set its time to push:

$ git push heroku master

You should see a lot of logging and after your bot should be up and running.

If you have any issues you can review the heroku logs:

$ heroku logs

Your bot should now be deployed!

Deploying to Unix

There are a number of ways to deploy to unix. The recommended way is to create a release of Butler with exrm and run the release on your vps or server of choice.

Contributing

Butler is still a work in progress and we appreciate any contributions. If you have questions then feel free to open an issue.

butler's People

Contributors

keathley avatar wa9ace avatar bbrock25 avatar

Stargazers

 avatar Gio d'Amelio avatar Mikal avatar Rogelio Orts avatar Julian Pokrovsky avatar undr avatar Jeff Smith avatar Erik Nilsen avatar  avatar Roman Heinrich avatar Maximilian Schulz avatar Jamie Wright avatar Heri Sim avatar Bill Gloff avatar Sander avatar Alex Kaminsky avatar  avatar Andy Eskridge avatar Craig Lyons avatar Paulo A Pereira avatar Sean Brewer avatar  avatar Christoph Grabo avatar  avatar

Watchers

Paulo A Pereira avatar James Cloos avatar  avatar  avatar  avatar

butler's Issues

"Help" plugin

People should be able to ask butler for help and he should be able to tell them about the plugins that they have installed. Ideally this could be its own plugin...but it might need to be wrapped into butler directly.

running adapters as apps?

Does it make sense to run each adapter as its own application? What would the pros and cons of that be?

Add history to the console adapter

It would be really convenient to have history in the console adapter like in a standard repl or terminal. This will probably involve writing directly to tty or something similar in order to capture the up arrow and down arrow keys.

Respond to more slack messages

There a several slack messages that we don't currently respond to. The full list is here: https://api.slack.com/rtm. Here's what I can think of off the top of my head:

  • hello
  • channel_created
  • channel_joined
  • channel_left
  • channel_rename
  • channel_archive
  • channel_unarchive
  • group_joined
  • group_left
  • group_rename
  • group_archive
  • group_unarchive
  • team_rename
  • team_join
  • user_change
  • bot_added
  • bot_changed

We can use each of these to update the adapter about the state of slack.

Installation command in README.md does not work

The Readme suggests to install the butler archive with the following command:

mix archive.install https://github.com/butlerbot/butler/releases/download/v0.7.1/butler_new-0.7.1.ez

The command fails because butler_new-0.7.1.ez does not exist which becomes clear on the Releases page of the repository: https://github.com/keathley/butler/releases

As 0.7.1 seems to be just documentation I just downloaded 0.7.0 as a workaround but I still wanted to open an issue on that matter.

Use macros so plugins can use regex matching

I think that we should probably be using some sort of macro so that we can do regex matching on incoming patterns. I'm not sure what the details would look like since we need to be able to pass in the state of plugin and then any capture groups that are included in the regex. Ideally it would also be good to check these sorts of things at compile time instead of runtime.

Anyone have thoughts on how we can do this?

CC @colinrymer

heroku boot timeout

for running butler on heroku, I keep getting an Error, R10 (Boot Timeout);

2015-11-07T21:49:15.389471+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-11-07T21:49:15.389471+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-11-07T21:49:16.030841+00:00 heroku[web.1]: Process exited with status 137
2015-11-07T21:49:16.054402+00:00 heroku[web.1]: State changed from starting to crashed

Not sure if I missed a step in the configuration, but it seems that heroku is looking for a port to bind to for this app? Do we need to open an endpoint for heroku to verify the app is alive?

Butler reload plugin

It would be useful to be able to tell Butler to update and reload himself via a plugin.

Butler needs a face

Butler needs a persona. Anyone wanna try their hand at some illustration work?

Butler.Adapter.Console isn't capturing tty output

Not sure what happened in the most recent commits, but for some reason, when I run

iex -S mix

I get the following output:

bbrock:butler/ (feature-docs✗) $ iex -S mix                                              [12:56:36]
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Compiled lib/butler/adapters/slack/rtm.ex
Compiled lib/butler.ex
Compiled lib/butler/supervisor.ex
Compiled lib/butler/plugin.ex
Compiled lib/butler/adapters/console.ex
Compiled lib/butler/message.ex
Compiled lib/butler/bot.ex
Compiled lib/butler/adapters/slack.ex
Compiled lib/butler/plugins/cowsay.ex
Compiled lib/butler/plugins/test_count.ex
Generated butler app
butler>Interactive Elixir (1.0.5) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

It seems that the iex repl is taking back over and dropping the butler> prompt. I'll dig into it, but wasn't sure if it was something simple that I missed.

Butler.Adapter.Slack is still functional

Hot code reloading

It would be really rad to get hot code reloading working in development so that its easier for end users to write plugins and such.

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.