diff options
Diffstat (limited to 'lib/irc')
-rw-r--r-- | lib/irc/connection.ex | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/irc/connection.ex b/lib/irc/connection.ex index 52910ac..fafb0d7 100644 --- a/lib/irc/connection.ex +++ b/lib/irc/connection.ex @@ -264,8 +264,11 @@ defmodule IRC.Connection do # ISUP def handle_info({:isup, network}, state) do - IRC.UserTrack.clear_network(network) - {:noreply, %{state | network: network}} + IRC.UserTrack.clear_network(state.network) + if network != state.network do + Logger.warn("Possibly misconfigured network: #{network} != #{state.network}") + end + {:noreply, state} end # Been kicked @@ -276,11 +279,11 @@ defmodule IRC.Connection do # Received something in a channel def handle_info({:received, text, sender, chan}, state) do - user = IRC.UserTrack.find_by_nick(network(state), sender.nick) + user = IRC.UserTrack.find_by_nick(state.network, sender.nick) if !Map.get(user.options, :puppet) do reply_fun = fn(text) -> irc_reply(state, {chan, sender}, text) end account = IRC.Account.lookup(sender) - message = %IRC.Message{at: NaiveDateTime.utc_now(), text: text, network: network(state), account: account, sender: sender, channel: chan, replyfun: reply_fun, trigger: extract_trigger(text)} + message = %IRC.Message{at: NaiveDateTime.utc_now(), text: text, network: state.network, account: account, sender: sender, channel: chan, replyfun: reply_fun, trigger: extract_trigger(text)} message = case IRC.UserTrack.messaged(message) do :ok -> message {:ok, message} -> message @@ -294,7 +297,7 @@ defmodule IRC.Connection do def handle_info({:received, text, sender}, state) do reply_fun = fn(text) -> irc_reply(state, {sender.nick, sender}, text) end account = IRC.Account.lookup(sender) - message = %IRC.Message{text: text, network: network(state), account: account, sender: sender, replyfun: reply_fun, trigger: extract_trigger(text)} + message = %IRC.Message{text: text, network: state.network, account: account, sender: sender, replyfun: reply_fun, trigger: extract_trigger(text)} message = case IRC.UserTrack.messaged(message) do :ok -> message {:ok, message} -> message @@ -357,22 +360,22 @@ defmodule IRC.Connection do end def handle_info({:kicked, nick, _by, channel, _reason}, state) do - IRC.UserTrack.parted(network(state), channel, nick) + IRC.UserTrack.parted(state.network, channel, nick) {:noreply, state} end def handle_info({:parted, channel, %ExIRC.SenderInfo{nick: nick}}, state) do - IRC.UserTrack.parted(network(state), channel, nick) + IRC.UserTrack.parted(state.network, channel, nick) {:noreply, state} end def handle_info({:mode, [channel, mode, nick]}, state) do - track_mode(network(state), channel, nick, mode) + track_mode(state.network, channel, nick, mode) {:noreply, state} end def handle_info({:nick_changed, old_nick, new_nick}, state) do - IRC.UserTrack.renamed(network(state), old_nick, new_nick) + IRC.UserTrack.renamed(state.network, old_nick, new_nick) {:noreply, state} end @@ -499,13 +502,4 @@ defmodule IRC.Connection do host <> ":" <> to_string(port) end - defp network(state = %{conn: %{network: network}}) do - if network do - network - else - # FIXME performance meheeeee - ExIRC.Client.state(state.client)[:network] - end - end - end |