Replace all other State.cfg/0 in favor of Irc.cfg/1

State.cfg/0 should be removed from the codebase by this point. Should be
safe to remove.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-08-11 12:52:37 -07:00
parent 6110420015
commit 2dc7bbd94d
4 changed files with 10 additions and 8 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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, " ")

View File

@@ -1,4 +1,4 @@
defmodule Omnibot.PluginSupervisor do
defmodule Omnibot.PluginManager do
@moduledoc false
use Supervisor