Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wasnotrice/clover
A chat bot framework for Elixir applications
https://github.com/wasnotrice/clover
Last synced: about 1 month ago
JSON representation
A chat bot framework for Elixir applications
- Host: GitHub
- URL: https://github.com/wasnotrice/clover
- Owner: wasnotrice
- License: apache-2.0
- Created: 2018-10-15T18:03:38.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-06T20:29:19.000Z (about 6 years ago)
- Last Synced: 2024-09-16T17:47:37.062Z (2 months ago)
- Language: Elixir
- Size: 170 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![version badge](https://img.shields.io/hexpm/v/clover.svg?style=for-the-badge)
![ci badge](https://img.shields.io/circleci/project/github/wasnotrice/clover/master.svg?style=for-the-badge)
![code coverage badge](https://img.shields.io/coveralls/github/wasnotrice/clover/master.svg?style=for-the-badge)
![license badge](https://img.shields.io/github/license/wasnotrice/clover.svg?style=for-the-badge)# Clover
Clover is a framework for building chat bots in Elixir. It takes inspiration from [Hubot](https://hubot.github.com/) and [Hedwig](https://github.com/hedwig-im/hedwig). Like Hubot and Hedwig, Clover:
- uses adapters so you can connect your bot to various platforms
- allows you to specify multiple handlers for incoming messages
- associates a regular expression for matching messages with a function that transforms the message into a responseLike Hedwig, Clover:
- supervises processes for fault tolerance
Clover adds some features:
- matches each incoming message with at most one handler (e.g., no double responses)
- allows you to start your robot under Clover's supervision tree, or under your own
- configuration happens at runtime, not through application configPlanned features for Clover:
- only ever responds to messages addressed to your robot (e.g., no "hear" handlers)
- maintains "room state", so your robot can carry on conversations
- handles messages in their own worker processes## Installation
The package can be installed by adding `clover` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:clover, "~> 0.1.0"}
]
end
```## Creating your robot
_Coming soon. See the [Test Robot](test/support/test_robot.ex) for an example._
## Starting your robot
Clover bots always run under a `Clover.Robot.Supervisor` process. The supervisor handles crashes in your robot or in its adapter, and restarts processes as needed. However, you have some choice as to who supervises the supervisor.
Let's say you have a Clover bot called `Mybot`. To start a robot under Clover's supervision tree, provide a name, your bot's module, and an adapter:
```elixir
Clover.start_supervised_robot("mybot", Mybot, {Clover.Adapter.Slack, token: "my-slack-bot-token"})
```Clover will start your robot under its own supervision tree, and manage it for you.
_(The name you provide here will be used to register your robot with Clover. It's not your robot's chat nick.)_
To handle supervision yourself:
```elixir
Clover.start_robot("mybot", Mybot, {Clover.Adapter.Slack, token: "my-slack-bot-token"})
```The individual robot and adapter processes will still be supervised by a `Clover.Robot.Supervisor`, but you can place this process into your own supervision tree, for greater control over its lifecycle.
## Adapters
Clover is designed to support multiple chat platforms through adapters. Currently, there is a test adapter bundled with Clover, and a Slack adapter (which is also bundled with Clover, but will be pulled out in the future).