DasBot

DasBot is like Plug, but for Slack.

Online documentation is available here.

Example

defmodule MyBot do
use DasBot.Bot
slug(DasBot.Slug.Common.MessagesOnly)
slug(DasBot.Slug.Common.CheckMentioned)
slug(:simple_reply)
def simple_reply(%DasBot.Event{data: %{user: user_id}, metadata: %{mentioned: true}} = event) do
DasBot.Bot.send_to_channel(__MODULE__, "general", "Oh hey, <@\#{user_id}>!")
event
end
def simple_reply(event), do: event
end

Installation

Add DasBot to your project's dependencies.

def deps do
[
{:das_bot, "~> 0.1.0"}
]
end

Start your bot as a worker in your OTP application, passing your slack bot API token as an argument.

defmodule MyBot.Application do
@moduledoc false
use Application
def start(_type, _args) do
children = [{MyBot, token: "xoxb-my-bot-token"}]
opts = [strategy: :one_for_one, name: MyBot.Supervisor]
Supervisor.start_link(children, opts)
end
end