summaryrefslogtreecommitdiff
path: root/lib/irc/puppet_connection.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irc/puppet_connection.ex')
-rw-r--r--lib/irc/puppet_connection.ex28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/irc/puppet_connection.ex b/lib/irc/puppet_connection.ex
index 2604876..f5e2e5c 100644
--- a/lib/irc/puppet_connection.ex
+++ b/lib/irc/puppet_connection.ex
@@ -1,4 +1,4 @@
-defmodule IRC.PuppetConnection do
+defmodule Nola.Irc.PuppetConnection do
require Logger
@min_backoff :timer.seconds(5)
@max_backoff :timer.seconds(2*60)
@@ -12,8 +12,8 @@ defmodule IRC.PuppetConnection do
DynamicSupervisor.start_link(__MODULE__, [], name: __MODULE__)
end
- def start_child(%Nola.Account{id: account_id}, %IRC.Connection{id: connection_id}) do
- spec = %{id: {account_id, connection_id}, start: {IRC.PuppetConnection, :start_link, [account_id, connection_id]}, restart: :transient}
+ def start_child(%Nola.Account{id: account_id}, %Nola.Irc.Connection{id: connection_id}) do
+ spec = %{id: {account_id, connection_id}, start: {Nola.Irc.PuppetConnection, :start_link, [account_id, connection_id]}, restart: :transient}
DynamicSupervisor.start_child(__MODULE__, spec)
end
@@ -27,7 +27,7 @@ defmodule IRC.PuppetConnection do
end
end
- def whereis(account = %Nola.Account{id: account_id}, connection = %IRC.Connection{id: connection_id}) do
+ def whereis(account = %Nola.Account{id: account_id}, connection = %Nola.Irc.Connection{id: connection_id}) do
{:global, name} = name(account_id, connection_id)
case :global.whereis_name(name) do
:undefined -> nil
@@ -35,15 +35,15 @@ defmodule IRC.PuppetConnection do
end
end
- def send_message(account = %Nola.Account{id: account_id}, connection = %IRC.Connection{id: connection_id}, channel, text) do
+ def send_message(account = %Nola.Account{id: account_id}, connection = %Nola.Irc.Connection{id: connection_id}, channel, text) do
GenServer.cast(name(account_id, connection_id), {:send_message, self(), channel, text})
end
- def start_and_send_message(account = %Nola.Account{id: account_id}, connection = %IRC.Connection{id: connection_id}, channel, text) do
+ def start_and_send_message(account = %Nola.Account{id: account_id}, connection = %Nola.Irc.Connection{id: connection_id}, channel, text) do
{:global, name} = name(account_id, connection_id)
pid = whereis(account, connection)
pid = if !pid do
- case IRC.PuppetConnection.Supervisor.start_child(account, connection) do
+ case Nola.Irc.PuppetConnection.Supervisor.start_child(account, connection) do
{:ok, pid} -> pid
{:error, {:already_started, pid}} -> pid
end
@@ -53,8 +53,8 @@ defmodule IRC.PuppetConnection do
GenServer.cast(pid, {:send_message, self(), channel, text})
end
- def start(account = %Nola.Account{}, connection = %IRC.Connection{}) do
- IRC.PuppetConnection.Supervisor.start_child(account, connection)
+ def start(account = %Nola.Account{}, connection = %Nola.Irc.Connection{}) do
+ Nola.Irc.PuppetConnection.Supervisor.start_child(account, connection)
end
def start_link(account_id, connection_id) do
@@ -67,7 +67,7 @@ defmodule IRC.PuppetConnection do
def init([account_id, connection_id]) do
account = %Nola.Account{} = Nola.Account.get(account_id)
- connection = %IRC.Connection{} = IRC.Connection.lookup(connection_id)
+ connection = %Nola.Irc.Connection{} = Nola.Irc.Connection.lookup(connection_id)
Logger.metadata(puppet_conn: account.id <> "@" <> connection.id)
backoff = :backoff.init(@min_backoff, @max_backoff)
|> :backoff.type(:jitter)
@@ -85,7 +85,7 @@ defmodule IRC.PuppetConnection do
# ipv6
#end
- conn = IRC.Connection.lookup(state.connection_id)
+ conn = Nola.Irc.Connection.lookup(state.connection_id)
client_opts = []
|> Keyword.put(:network, conn.network)
client = if state.client && Process.alive?(state.client) do
@@ -150,14 +150,14 @@ defmodule IRC.PuppetConnection do
nick = make_nick(state)
sender = %ExIRC.SenderInfo{network: state.network, nick: suffix_nick(nick), user: nick, host: "puppet."}
reply_fun = fn(text) ->
- IRC.Connection.broadcast_message(state.network, channel, text)
+ Nola.Irc.Connection.broadcast_message(state.network, channel, text)
end
- message = %Nola.Message{id: FlakeId.get(), at: NaiveDateTime.utc_now(), text: text, network: state.network, account: account, sender: sender, channel: channel, replyfun: reply_fun, trigger: IRC.Connection.extract_trigger(text), meta: meta}
+ message = %Nola.Message{id: FlakeId.get(), at: NaiveDateTime.utc_now(), text: text, network: state.network, account: account, sender: sender, channel: channel, replyfun: reply_fun, trigger: Nola.Irc.Connection.extract_trigger(text), meta: meta}
message = case Nola.UserTrack.messaged(message) do
:ok -> message
{:ok, message} -> message
end
- IRC.Connection.publish(message, ["#{message.network}/#{channel}:messages"])
+ Nola.Irc.Connection.publish(message, ["#{message.network}/#{channel}:messages"])
idle = if length(state.buffer) == 0 do
:erlang.cancel_timer(state.idle)