diff --git a/lib/contrib/wordbot/wordbot.ex b/lib/contrib/wordbot/wordbot.ex index 30b5c8c..5bc1661 100644 --- a/lib/contrib/wordbot/wordbot.ex +++ b/lib/contrib/wordbot/wordbot.ex @@ -1,6 +1,6 @@ defmodule Omnibot.Contrib.Wordbot do use Omnibot.Plugin - alias Omnibot.{Contrib.Wordbot, State, Util} + alias Omnibot.{Contrib.Wordbot, Irc, Util} require Logger @default_config wordbot_source: "words.txt", wordbot_db: "wordbot.db", words_per_round: 300, hours_per_round: 5, ignore: [] @@ -162,7 +162,8 @@ defmodule Omnibot.Contrib.Wordbot do @impl true def on_join(irc, channel, who) do # Attempt to start a new round - if State.cfg().nick == who do + cfg = Irc.cfg(irc) + if cfg.nick == who do start_round(irc, channel) end end diff --git a/lib/core/core.ex b/lib/core/core.ex index 469660e..565b2c0 100644 --- a/lib/core/core.ex +++ b/lib/core/core.ex @@ -1,12 +1,12 @@ defmodule Omnibot.Core do use Omnibot.Plugin - alias Omnibot.State + alias Omnibot.{Irc, State} @default_config channels: :all @impl true def on_join(irc, channel, nick) do - cfg = State.cfg() + cfg = Irc.cfg(irc) if nick == cfg.nick do add_channel(channel) # Sync if we join a channel we shouldn't be in @@ -17,7 +17,7 @@ defmodule Omnibot.Core do @impl true def on_part(irc, channel, nick) do - cfg = State.cfg() + cfg = Irc.cfg(irc) if nick == cfg.nick do remove_channel(channel) # Sync if we join a channel we forcibly part a channel we shouldn't leave @@ -28,7 +28,7 @@ defmodule Omnibot.Core do @impl true def on_kick(irc, channel, _nick, target) do - cfg = State.cfg() + cfg = Irc.cfg(irc) if target == cfg.nick do remove_channel(channel) # Generally, being kicked is not intentionally leaving a channel, so always sync here diff --git a/lib/plugin/base.ex b/lib/plugin/base.ex index e9ed453..968e765 100644 --- a/lib/plugin/base.ex +++ b/lib/plugin/base.ex @@ -42,9 +42,10 @@ defmodule Omnibot.Plugin.Base do defp route_msg(irc, msg) do nick = msg.prefix.nick + cfg = Omnibot.Irc.cfg(irc) case String.upcase(msg.command) do "PRIVMSG" -> - if (!msg.prefix) || (msg.prefix.nick != Omnibot.State.cfg().nick) do + if (!msg.prefix) || (msg.prefix.nick != cfg.nick) do [channel | params] = msg.params line = Enum.join(params, " ") diff --git a/lib/plugin_supervisor.ex b/lib/plugin_manager.ex similarity index 97% rename from lib/plugin_supervisor.ex rename to lib/plugin_manager.ex index c9617a4..1a03336 100644 --- a/lib/plugin_supervisor.ex +++ b/lib/plugin_manager.ex @@ -1,4 +1,4 @@ -defmodule Omnibot.PluginSupervisor do +defmodule Omnibot.PluginManager do @moduledoc false use Supervisor