Current section
Files
Jump to
Current section
Files
lib/butler.ex
defmodule Butler do
@moduledoc ~S"""
Butler is a life betterment robot.
He is split into two main groups:
* `Butler.Adapter` - adapters allow butler to communicate with other
protocols and communications platforms.
* `Butler.Plugin` - plugins are what empower butler. They provide an api
to respond to specific commands and perform actions and replies.
## Adapters
`Butler.Adapter` is a generic behaviour that allows Butler to support
multiple chat platforms. There are two officialy supported adapters:
* `Butler.Adapters.Console` - used for local development.
* `Butler.Adapters.Slack` - for the slack chat platform.
You can read more about developing adapters in `Butler.Adapter`.
## Plugins
`Butler.Plugin` provides an api for developers to add functionality to
Butler. Plugins listen to events emitted by Butler and can choose to respond
or not. Here is an example plugin:
defmodule TestCount do
use Butler.Plugin
def respond("test count", tests) do
count = Enum.count(tests)
{:reply, "The count is #{count}", tests}
end
def hear("test", tests) do
{:noreply, ["test"|tests]}
end
end
If you want to read more about creating your own plugins in `Butler.Plugin`.
"""
use Application
@doc """
Starts Butler.
"""
def start(_type, [plugins]) do
Butler.Supervisor.start_link(plugins)
end
@doc """
Stops Butler.
"""
def stop(_) do
IO.puts "Cheerio"
end
end