Add deprecations for Omnibot.State functions
We're getting rid of the State hack module, because each IRC connection should hold onto its own config. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
19
lib/state.ex
19
lib/state.ex
@@ -1,4 +1,7 @@
|
||||
defmodule Omnibot.State do
|
||||
|
||||
@moduledoc ""
|
||||
|
||||
use GenServer
|
||||
|
||||
@enforce_keys [:cfg]
|
||||
@@ -6,6 +9,7 @@ defmodule Omnibot.State do
|
||||
|
||||
## Client API
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
def start_link(opts) do
|
||||
cfg = opts[:cfg]
|
||||
GenServer.start_link(__MODULE__, %Omnibot.State{
|
||||
@@ -13,31 +17,40 @@ defmodule Omnibot.State do
|
||||
}, opts)
|
||||
end
|
||||
|
||||
@deprecated "Use Irc.cfg/1 instead"
|
||||
@doc "Gets the current configuration from the default State process."
|
||||
def cfg(), do: cfg(__MODULE__)
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@doc "Gets the current configuration from the given State process."
|
||||
def cfg(state) do
|
||||
GenServer.call(state, :cfg)
|
||||
end
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@doc "Adds a loaded plugin to the default state."
|
||||
def add_loaded_plugin(plugin), do: add_loaded_plugin(__MODULE__, plugin)
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@doc "Adds a loaded plugin to the given state."
|
||||
def add_loaded_plugin(state, {plugin, cfg}), do: GenServer.cast(state, {:add_loaded_plugin, {plugin, cfg}})
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@doc "Adds a loaded plugin to the given state."
|
||||
def add_loaded_plugin(state, plugin), do: add_loaded_plugin(state, {plugin, []})
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@doc "Gets all loaded plugins from the default state."
|
||||
def loaded_plugins(), do: loaded_plugins(__MODULE__)
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@doc "Gets all loaded plugins from the given state."
|
||||
def loaded_plugins(state), do: GenServer.call(state, :loaded_plugins)
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
def all_channels(), do: all_channels(__MODULE__)
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
def all_channels(state) do
|
||||
loaded_plugins(state) |> Enum.flat_map(
|
||||
fn {_, cfg} ->
|
||||
@@ -51,8 +64,10 @@ defmodule Omnibot.State do
|
||||
|> MapSet.to_list()
|
||||
end
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
def channel_plugins(channel), do: channel_plugins(__MODULE__, channel)
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@doc ~S"""
|
||||
Gets a list of all `{plugin, plug_cfg}` from the given State that are both
|
||||
loaded, and listening to the given channel.
|
||||
@@ -66,21 +81,25 @@ defmodule Omnibot.State do
|
||||
|
||||
## Server API
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@impl true
|
||||
def init(state) do
|
||||
{:ok, state}
|
||||
end
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@impl true
|
||||
def handle_call(:cfg, _from, state) do
|
||||
{:reply, state.cfg, state}
|
||||
end
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@impl true
|
||||
def handle_call(:loaded_plugins, _from, state) do
|
||||
{:reply, state.plugin_map, state}
|
||||
end
|
||||
|
||||
@deprecated "Get rid of this"
|
||||
@impl true
|
||||
def handle_cast({:add_loaded_plugin, {plugin, cfg}}, state) do
|
||||
state = %{state | plugin_map: Map.put(state.plugin_map, plugin, cfg)}
|
||||
|
||||
Reference in New Issue
Block a user