From d17622a001592164a1708b04d1e73fd4568ab41f Mon Sep 17 00:00:00 2001 From: techgaun Date: Tue, 16 Aug 2016 23:21:14 -0500 Subject: [PATCH] add standup cron refs #1 --- config/config.exs | 2 ++ lib/ex_mustang.ex | 9 ++++++++- lib/ex_mustang/responders/quote.ex | 2 +- mix.exs | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/config/config.exs b/config/config.exs index 81ce33d..0211b20 100644 --- a/config/config.exs +++ b/config/config.exs @@ -27,6 +27,8 @@ config :ex_mustang, ExMustang.Robot, {ExMustang.Responders.Quote, []} ] +config :quantum, timezone: :local + # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this diff --git a/lib/ex_mustang.ex b/lib/ex_mustang.ex index 11e981b..d60cd68 100644 --- a/lib/ex_mustang.ex +++ b/lib/ex_mustang.ex @@ -12,10 +12,17 @@ defmodule ExMustang do # worker(ExMustang.Worker, [arg1, arg2, arg3]), worker(ExMustang.Robot, []) ] - + add_jobs() # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: ExMustang.Supervisor] Supervisor.start_link(children, opts) end + + def add_jobs do + Quantum.add_job(:standup, %Quantum.Job{ + schedule: Application.get_env(:ex_mustang, ExMustang.Responders.Standup)[:time_of_day], + task: fn -> ExMustang.Responders.Standup.run end + }) + end end diff --git a/lib/ex_mustang/responders/quote.ex b/lib/ex_mustang/responders/quote.ex index 6b611e3..e454cbc 100644 --- a/lib/ex_mustang/responders/quote.ex +++ b/lib/ex_mustang/responders/quote.ex @@ -2,7 +2,7 @@ defmodule ExMustang.Responders.Quote do @moduledoc """ Random Quote, FTW! - Sends random message each day or when someone says `quote` + Sends random message when someone says `quote` """ use Hedwig.Responder diff --git a/mix.exs b/mix.exs index 939922e..24c8caa 100644 --- a/mix.exs +++ b/mix.exs @@ -14,7 +14,7 @@ defmodule ExMustang.Mixfile do # # Type "mix help compile.app" for more information def application do - [applications: [:logger, :hedwig_slack], + [applications: [:logger, :hedwig_slack, :quantum, :tentacat], mod: {ExMustang, []}] end