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:
@@ -1,6 +1,6 @@
|
|||||||
defmodule Omnibot.Contrib.Wordbot do
|
defmodule Omnibot.Contrib.Wordbot do
|
||||||
use Omnibot.Plugin
|
use Omnibot.Plugin
|
||||||
alias Omnibot.{Contrib.Wordbot, State, Util}
|
alias Omnibot.{Contrib.Wordbot, Irc, Util}
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@default_config wordbot_source: "words.txt", wordbot_db: "wordbot.db", words_per_round: 300, hours_per_round: 5, ignore: []
|
@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
|
@impl true
|
||||||
def on_join(irc, channel, who) do
|
def on_join(irc, channel, who) do
|
||||||
# Attempt to start a new round
|
# 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)
|
start_round(irc, channel)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
defmodule Omnibot.Core do
|
defmodule Omnibot.Core do
|
||||||
use Omnibot.Plugin
|
use Omnibot.Plugin
|
||||||
alias Omnibot.State
|
alias Omnibot.{Irc, State}
|
||||||
|
|
||||||
@default_config channels: :all
|
@default_config channels: :all
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def on_join(irc, channel, nick) do
|
def on_join(irc, channel, nick) do
|
||||||
cfg = State.cfg()
|
cfg = Irc.cfg(irc)
|
||||||
if nick == cfg.nick do
|
if nick == cfg.nick do
|
||||||
add_channel(channel)
|
add_channel(channel)
|
||||||
# Sync if we join a channel we shouldn't be in
|
# Sync if we join a channel we shouldn't be in
|
||||||
@@ -17,7 +17,7 @@ defmodule Omnibot.Core do
|
|||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def on_part(irc, channel, nick) do
|
def on_part(irc, channel, nick) do
|
||||||
cfg = State.cfg()
|
cfg = Irc.cfg(irc)
|
||||||
if nick == cfg.nick do
|
if nick == cfg.nick do
|
||||||
remove_channel(channel)
|
remove_channel(channel)
|
||||||
# Sync if we join a channel we forcibly part a channel we shouldn't leave
|
# 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
|
@impl true
|
||||||
def on_kick(irc, channel, _nick, target) do
|
def on_kick(irc, channel, _nick, target) do
|
||||||
cfg = State.cfg()
|
cfg = Irc.cfg(irc)
|
||||||
if target == cfg.nick do
|
if target == cfg.nick do
|
||||||
remove_channel(channel)
|
remove_channel(channel)
|
||||||
# Generally, being kicked is not intentionally leaving a channel, so always sync here
|
# Generally, being kicked is not intentionally leaving a channel, so always sync here
|
||||||
|
|||||||
@@ -42,9 +42,10 @@ defmodule Omnibot.Plugin.Base do
|
|||||||
|
|
||||||
defp route_msg(irc, msg) do
|
defp route_msg(irc, msg) do
|
||||||
nick = msg.prefix.nick
|
nick = msg.prefix.nick
|
||||||
|
cfg = Omnibot.Irc.cfg(irc)
|
||||||
case String.upcase(msg.command) do
|
case String.upcase(msg.command) do
|
||||||
"PRIVMSG" ->
|
"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
|
[channel | params] = msg.params
|
||||||
line = Enum.join(params, " ")
|
line = Enum.join(params, " ")
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
defmodule Omnibot.PluginSupervisor do
|
defmodule Omnibot.PluginManager do
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
|
|
||||||
use Supervisor
|
use Supervisor
|
||||||
Reference in New Issue
Block a user