diff options
author | Jordan Bracco <href@random.sh> | 2022-12-20 15:03:45 +0000 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2022-12-20 19:29:42 +0100 |
commit | d476f949136571a89eb0a1ada1a0e112c6a1dfb5 (patch) | |
tree | c96a18742428175c639fd14b1053b73615ab12e7 | |
parent | chore: config example update, add version to footer, remove useless module, r... (diff) |
Finish renaming IRC to Nola.Irc, refs T77.
-rw-r--r-- | lib/irc.ex | 2 | ||||
-rw-r--r-- | lib/irc/admin_handler.ex | 6 | ||||
-rw-r--r-- | lib/matrix/room.ex | 2 | ||||
-rw-r--r-- | lib/nola/user_track.ex | 2 | ||||
-rw-r--r-- | lib/plugins/account.ex | 2 | ||||
-rw-r--r-- | lib/plugins/base.ex | 2 | ||||
-rw-r--r-- | lib/plugins/say.ex | 2 | ||||
-rw-r--r-- | lib/plugins/txt.ex | 4 | ||||
-rw-r--r-- | lib/telegram.ex | 2 | ||||
-rw-r--r-- | lib/telegram/room.ex | 6 | ||||
-rw-r--r-- | lib/web/controllers/irc_controller.ex | 2 | ||||
-rw-r--r-- | lib/web/controllers/page_controller.ex | 2 | ||||
-rw-r--r-- | lib/web/live/chat_live.ex | 4 |
13 files changed, 19 insertions, 19 deletions
@@ -18,7 +18,7 @@ defmodule Nola.Irc do def admin?(%Message{sender: sender}), do: admin?(sender) def admin?(%{nick: nick, user: user, host: host}) do - for {n, u, h} <- Nola.IRC.env(:admins, []) do + for {n, u, h} <- Nola.Irc.env(:admins, []) do admin_part_match?(n, nick) && admin_part_match?(u, user) && admin_part_match?(h, host) end |> Enum.any? diff --git a/lib/irc/admin_handler.ex b/lib/irc/admin_handler.ex index a462789..cb953db 100644 --- a/lib/irc/admin_handler.ex +++ b/lib/irc/admin_handler.ex @@ -14,12 +14,12 @@ defmodule Nola.Irc.AdminHandler do def init([client]) do ExIRC.Client.add_handler client, self - :ok = IRC.register("op") + {:ok, _} = Registry.register(Nola.PubSub, "op", []) {:ok, client} end def handle_info({:irc, :trigger, "op", m = %Nola.Message{trigger: %Nola.Trigger{type: :bang}, sender: sender}}, client) do - if IRC.admin?(sender) do + if Nola.Irc.admin?(sender) do m.replyfun.({:mode, "+o"}) else m.replyfun.({:kick, "non"}) @@ -28,7 +28,7 @@ defmodule Nola.Irc.AdminHandler do end def handle_info({:joined, chan, sender}, client) do - if IRC.admin?(sender) do + if Nola.Irc.admin?(sender) do ExIRC.Client.mode(client, chan, "+o", sender.nick) end {:noreply, client} diff --git a/lib/matrix/room.ex b/lib/matrix/room.ex index 299d7cc..e2965a5 100644 --- a/lib/matrix/room.ex +++ b/lib/matrix/room.ex @@ -162,7 +162,7 @@ defmodule Nola.Matrix.Room do end def handle_matrix(event = %{type: "m.room.message", user_id: user_id, content: %{"msgtype" => "m.text", "body" => text}}, state) do - IRC.send_message_as(get_account(event, state), state.network, state.channel, text, true) + Nola.Irc.send_message_as(get_account(event, state), state.network, state.channel, text, true) {:noreply, state} end diff --git a/lib/nola/user_track.ex b/lib/nola/user_track.ex index f6a02ae..c1218b0 100644 --- a/lib/nola/user_track.ex +++ b/lib/nola/user_track.ex @@ -199,7 +199,7 @@ defmodule Nola.UserTrack do def joined(c, s), do: joined(c,s,[]) def joined(channel, sender=%{nick: nick, user: uname, host: host}, privileges, touch \\ true) do - privileges = if IRC.admin?(sender) do + privileges = if Nola.Irc.admin?(sender) do privileges ++ [:admin] else privileges end user = if user = find_by_nick(sender.network, nick) do diff --git a/lib/plugins/account.ex b/lib/plugins/account.ex index 20abab7..242b290 100644 --- a/lib/plugins/account.ex +++ b/lib/plugins/account.ex @@ -102,7 +102,7 @@ defmodule Nola.Plugins.Account do code = String.downcase(EntropyString.small_id()) Nola.Account.put_meta(m.account, "sms-validation-code", code) Nola.Account.put_meta(m.account, "sms-validation-target", m.network) - number = Nola.IRC.Sms.my_number() + number = Nola.Plugin.Sms.my_number() text = "To enable or change your number for SMS messaging, please send:" <> " \"enable #{code}\" to #{number}" m.replyfun.(text) diff --git a/lib/plugins/base.ex b/lib/plugins/base.ex index 3188495..0f2c7e5 100644 --- a/lib/plugins/base.ex +++ b/lib/plugins/base.ex @@ -86,7 +86,7 @@ defmodule Nola.Plugins.Base do pid when is_pid(pid) <- GenServer.whereis(module), :ok <- GenServer.stop(pid) do - IRC.Plugin.switch(module, false) + Nola.Plugins.switch(module, false) m.replyfun.("stopped: #{inspect(pid)}") else false -> m.replyfun.("not loaded") diff --git a/lib/plugins/say.ex b/lib/plugins/say.ex index 3df3ac8..114ca64 100644 --- a/lib/plugins/say.ex +++ b/lib/plugins/say.ex @@ -62,7 +62,7 @@ defmodule Nola.Plugins.Say do chan2 = String.replace(chan, "#", "") if (target == "#{net}/#{chan}" || target == "#{net}/#{chan2}" || target == chan || target == chan2) do if with_nick? do - IRC.send_message_as(account, net, chan, text) + Nola.Irc.send_message_as(account, net, chan, text) else Nola.Irc.Connection.broadcast_message(net, chan, text) end diff --git a/lib/plugins/txt.ex b/lib/plugins/txt.ex index 4f9a803..3b431e9 100644 --- a/lib/plugins/txt.ex +++ b/lib/plugins/txt.ex @@ -520,7 +520,7 @@ defmodule Nola.Plugins.Txt do end defp can_write?(%{rw: rw?, locks: locks}, msg = %{channel: nil, sender: sender}, trigger) do - admin? = IRC.admin?(sender) + admin? = Nola.Irc.admin?(sender) locked? = case :dets.lookup(locks, trigger) do [{trigger}] -> true _ -> false @@ -537,7 +537,7 @@ defmodule Nola.Plugins.Txt do end defp can_write?(state = %__MODULE__{rw: rw?, locks: locks}, msg = %{channel: channel, sender: sender}, trigger) do - admin? = IRC.admin?(sender) + admin? = Nola.Irc.admin?(sender) operator? = Nola.UserTrack.operator?(msg.network, channel, sender.nick) locked? = case :dets.lookup(locks, trigger) do [{trigger}] -> true diff --git a/lib/telegram.ex b/lib/telegram.ex index dcd8b1f..f2c9eca 100644 --- a/lib/telegram.ex +++ b/lib/telegram.ex @@ -145,7 +145,7 @@ defmodule Nola.Telegram do path = NolaWeb.Router.Helpers.url(NolaWeb.Endpoint) <> "/files/#{s3path}" sent = for {net, chan} <- target do txt = "sent#{type}#{text} #{path}" - IRC.send_message_as(account, net, chan, txt) + Nola.Irc.send_message_as(account, net, chan, txt) "#{net}/#{chan}" end if caption = op["caption"], do: as_irc_message(chat_id, caption, account) diff --git a/lib/telegram/room.ex b/lib/telegram/room.ex index f3c3715..ede939e 100644 --- a/lib/telegram/room.ex +++ b/lib/telegram/room.ex @@ -96,14 +96,14 @@ defmodule Nola.TelegramRoom do def handle_update(%{"message" => %{"from" => from = %{"id" => user_id}, "text" => text}}, _token, state) do account = find_or_create_meta_account(from, state) connection = Nola.Irc.Connection.get_network(state.net) - IRC.send_message_as(account, state.net, state.chan, text, true) + Nola.Irc.send_message_as(account, state.net, state.chan, text, true) {:ok, state} end def handle_update(data = %{"message" => %{"from" => from = %{"id" => user_id}, "location" => %{"latitude" => lat, "longitude" => lon}}}, _token, state) do account = find_or_create_meta_account(from, state) connection = Nola.Irc.Connection.get_network(state.net) - IRC.send_message_as(account, state.net, state.chan, "@ #{lat}, #{lon}", true) + Nola.Irc.send_message_as(account, state.net, state.chan, "@ #{lat}, #{lon}", true) {:ok, state} end @@ -173,7 +173,7 @@ defmodule Nola.TelegramRoom do path = NolaWeb.Router.Helpers.url(NolaWeb.Endpoint) <> "/files/#{s3path}" txt = "#{type}: #{text}#{path}" connection = Nola.Irc.Connection.get_network(state.net) - IRC.send_message_as(account, state.net, state.chan, txt, true) + Nola.Irc.send_message_as(account, state.net, state.chan, txt, true) else error -> Telegram.Api.request(token, "sendMessage", chat_id: chat_id, text: "File upload failed, sorry.") diff --git a/lib/web/controllers/irc_controller.ex b/lib/web/controllers/irc_controller.ex index d2ba04a..e87382b 100644 --- a/lib/web/controllers/irc_controller.ex +++ b/lib/web/controllers/irc_controller.ex @@ -42,7 +42,7 @@ defmodule NolaWeb.IrcController do defp do_txt(conn, nil) do - doc = Nola.IRC.Txt.irc_doc() + doc = Nola.Plugins.Txt.irc_doc() data = data() main = Enum.filter(data, fn({trigger, _}) -> !String.contains?(trigger, ".") end) |> Enum.into(Map.new) system = Enum.filter(data, fn({trigger, _}) -> String.contains?(trigger, ".") end) |> Enum.into(Map.new) diff --git a/lib/web/controllers/page_controller.ex b/lib/web/controllers/page_controller.ex index bf79413..cb46b8f 100644 --- a/lib/web/controllers/page_controller.ex +++ b/lib/web/controllers/page_controller.ex @@ -33,7 +33,7 @@ defmodule NolaWeb.PageController do end def irc(conn, _) do - bot_helps = for mod <- Nola.IRC.env(:handlers) do + bot_helps = for mod <- Nola.Irc.env(:handlers) do mod.irc_doc() end render conn, "irc.html", bot_helps: bot_helps diff --git a/lib/web/live/chat_live.ex b/lib/web/live/chat_live.ex index f8bab7d..8a9f6f2 100644 --- a/lib/web/live/chat_live.ex +++ b/lib/web/live/chat_live.ex @@ -22,7 +22,7 @@ defmodule NolaWeb.ChatLive do Map.put(acc, id, user) end) - backlog = case Nola.IRC.Buffer.select_buffer(connection.network, chan) do + backlog = case Nola.Plugins.Buffer.select_buffer(connection.network, chan) do {backlog, _} -> {backlog, _} = Enum.reduce(backlog, {backlog, nil}, &reduce_contextual_event/2) Enum.reverse(backlog) @@ -48,7 +48,7 @@ defmodule NolaWeb.ChatLive do def handle_event("send", %{"message" => %{"text" => text}}, socket) do account = Nola.Account.get(socket.assigns.account_id) - IRC.send_message_as(account, socket.assigns.network, socket.assigns.channel, text, true) + Nola.Irc.send_message_as(account, socket.assigns.network, socket.assigns.channel, text, true) {:noreply, assign(socket, :counter, socket.assigns.counter + 1)} end |