Skip to content

Commit

Permalink
standup stuffs closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
techgaun committed Aug 17, 2016
1 parent 46bca3b commit 9ce8f9a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use Mix.Config

config :ex_mustang, ExMustang.Responders.Standup,
time_of_day: "30 10 * * 1-5",
slack_channel: System.get_env("STANDUP_CHANNEL") || "general"
slack_channel: System.get_env("STANDUP_CHANNEL") || "general",
suffix: ["folks", "hackers", "peeps", "avengers"],
msg: "Standup time"

config :ex_mustang, ExMustang.Responders.Github,
repos: ["techgaun/ex_mustang"],
Expand Down
13 changes: 12 additions & 1 deletion lib/ex_mustang/responders/standup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@ defmodule ExMustang.Responders.Standup do
Module that sends message when its Standup time
"""

@doc """
Function to call for sending standup notice
"""
def run do

msg = %Hedwig.Message{
type: "message",
room: "#{config[:slack_channel]}",
text: "#{config[:msg]}, #{Hedwig.Responder.random(config[:suffix])}!",
}
pid = Hedwig.whereis("mustang")
Hedwig.Robot.send(pid, msg)
end

defp config, do: Application.get_env(:ex_mustang, ExMustang.Responders.Standup)
end
6 changes: 6 additions & 0 deletions lib/ex_mustang/robot.ex
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
defmodule ExMustang.Robot do
use Hedwig.Robot, otp_app: :ex_mustang

def after_connect(state) do
Hedwig.Registry.register(state.name)

{:ok, state}
end
end

0 comments on commit 9ce8f9a

Please # to comment.