Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/willrax/marvin
:space_invader: Slack bots using Elixir.
https://github.com/willrax/marvin
Last synced: 14 days ago
JSON representation
:space_invader: Slack bots using Elixir.
- Host: GitHub
- URL: https://github.com/willrax/marvin
- Owner: willrax
- Created: 2015-12-27T20:09:57.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-04T08:10:42.000Z (about 8 years ago)
- Last Synced: 2024-10-04T15:33:27.838Z (about 1 month ago)
- Language: Elixir
- Homepage: http://hexdocs.pm/marvin/
- Size: 29.3 KB
- Stars: 15
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Marvin
Slack bots using Elixir.
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
1. Add Marvin to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:marvin, "~> 0.3.1"},
{:websocket_client, git: "https://github.com/jeremyong/websocket_client"}
]
end
```You'll need to add `websocket_client` manually.
2. Ensure marvin is started before your application:
```elixir
def application do
[applications: [:marvin]]
end
```You'll need to set your bots Slack token in your applications config file.
```elixir
config :marvin, slack_token: "secret"
```## Creating Bots
Bots are simple to create and can respond to mentions, direct messages and ambient conversation.
```elixir
defmodule EchoBot do
use Marvin.Bot# Here you can set a specific type of message and a regex pattern to match against
# Direct includes mentions and direct discussions with the bot. Patterns are case
# sensitive by default.match {:direct, ~r/hello/}
def handle_message(message, slack) do
send_message("Hi!", message.channel, slack)
end
end
```Next you'll need to tell Marvin to start your bots by adding them to your config file.
```elixir
config :marvin, bots: [EchoBot]
```You can also capture reactions being applied to a message.
```elixir
defmodule EchoBot do
use Marvin.Botmatch {:reaction, "coin"}
def handle_message(message, slack) do
IO.puts "A coin was given"
end
end