diff options
author | href <href@random.sh> | 2021-09-01 10:30:18 +0200 |
---|---|---|
committer | href <href@random.sh> | 2021-09-01 10:30:18 +0200 |
commit | 75687711f35355bc30e4829439384aab28fcac6d (patch) | |
tree | 8f3256f472893c39720a684d390e890a152f7303 /lib/lsg_irc/coronavirus_plugin.ex | |
parent | link: post_* callbacks; html & pdftitle. (diff) |
Commit all the changes that hasn't been committed + updates.
Diffstat (limited to 'lib/lsg_irc/coronavirus_plugin.ex')
-rw-r--r-- | lib/lsg_irc/coronavirus_plugin.ex | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/lsg_irc/coronavirus_plugin.ex b/lib/lsg_irc/coronavirus_plugin.ex index 8038d14..b9a9e40 100644 --- a/lib/lsg_irc/coronavirus_plugin.ex +++ b/lib/lsg_irc/coronavirus_plugin.ex @@ -14,15 +14,22 @@ defmodule LSG.IRC.CoronavirusPlugin do """ def irc_doc, do: @moduledoc - def start_link(), do: GenServer.start_link(__MODULE__, []) + def start_link() do + GenServer.start_link(__MODULE__, [], name: __MODULE__) + end def init(_) do - {:ok, _} = Registry.register(IRC.PubSub, "trigger:coronavirus", []) + {:ok, _} = Registry.register(IRC.PubSub, "trigger:coronavirus", [plugin: __MODULE__]) + {:ok, nil, {:continue, :init}} + :ignore + end + + def handle_continue(:init, _) do date = Date.add(Date.utc_today(), -2) {data, _} = fetch_data(%{}, date) {data, next} = fetch_data(data) :timer.send_after(next, :update) - {:ok, %{data: data}} + {:noreply, %{data: data}} end def handle_info(:update, state) do @@ -163,4 +170,3 @@ defmodule LSG.IRC.CoronavirusPlugin do end end - |