summaryrefslogtreecommitdiff
path: root/lib/irc/connection.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irc/connection.ex')
-rw-r--r--lib/irc/connection.ex11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/irc/connection.ex b/lib/irc/connection.ex
index b83c4d3..bdcc658 100644
--- a/lib/irc/connection.ex
+++ b/lib/irc/connection.ex
@@ -183,9 +183,10 @@ defmodule IRC.Connection do
end
def init([conn]) do
+ Logger.metadata(conn: conn.id)
backoff = :backoff.init(@min_backoff, @max_backoff)
|> :backoff.type(:jitter)
- {:ok, %{client: nil, backoff: backoff, conn: conn}, {:continue, :connect}}
+ {:ok, %{client: nil, backoff: backoff, conn: conn, connected_server: nil, connected_port: nil, network: nil}, {:continue, :connect}}
end
@triggers %{
@@ -243,7 +244,7 @@ defmodule IRC.Connection do
Logger.info("#{inspect(self())} Connected to #{server}:#{port} #{inspect state}")
{_, backoff} = :backoff.succeed(state.backoff)
ExIRC.Client.logon(state.client, state.conn.pass || "", state.conn.nick, state.conn.user, state.conn.name)
- {:noreply, %{state | backoff: backoff}}
+ {:noreply, %{state | backoff: backoff, connected_server: server, connected_port: port}}
end
# Logon successful
@@ -254,6 +255,12 @@ defmodule IRC.Connection do
{:noreply, %{state | backoff: backoff}}
end
+ # ISUP
+ def handle_info({:isup, network}, state) do
+ IRC.UserTrack.clear_network(network)
+ {:noreply, %{state | network: network}}
+ end
+
# Been kicked
def handle_info({:kicked, _sender, chan, _reason}, state) do
ExIRC.Client.join(state.client, chan)