I’ve been working on a Slack bot framework inspired by Plug.
# lib/bot_family/my_bot.ex
defmodule BotFamily.MyBot do
use ExBot.Bot
slug(ExBot.Slug.Common.MessagesOnly)
slug(ExBot.Slug.Common.CheckMentioned)
slug(:simple_reply)
def simple_reply(%ExBot.Event{data: event_data, metadata: %{mentioned: true}} = event) do
%{user: user_id, channel: channel_id} = event_data
ExBot.Bot.send_text(__MODULE__, channel_id, "Oh hey, <@#{user_id}>!")
event
end
def simple_reply(event), do: event
end
You can assemble a pipeline of “slugs” that receive Slack events, take actions, and annotate the event as it moves through the pipeline.
It’s nothing fancy yet, but I thought I’d share it all the same