summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2022-12-11 01:16:45 +0000
committerJordan Bracco <href@random.sh>2022-12-11 02:03:36 +0000
commite7e84446086b474ed7a1f3de5d6ba69e60c34561 (patch)
treef501995b7301d6e3697b9adbf85feb611bc6e637 /lib
parentfeat: derive Poison for IRC.{Account, Message} (diff)
fix(irc-connection): attempt to find or create/join user in track when receiving a message
Diffstat (limited to 'lib')
-rw-r--r--lib/irc/connection.ex12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/irc/connection.ex b/lib/irc/connection.ex
index 0980262..fcb6c5e 100644
--- a/lib/irc/connection.ex
+++ b/lib/irc/connection.ex
@@ -279,9 +279,17 @@ defmodule IRC.Connection do
# Received something in a channel
def handle_info({:received, text, sender, chan}, state) do
- user = IRC.UserTrack.find_by_nick(state.network, sender.nick)
+ user = if user = IRC.UserTrack.find_by_nick(state.network, sender.nick) do
+ user
+ else
+ Logger.error("Could not lookup user for message: #{inspect {state.network, chan, sender.nick}}")
+ user = IRC.UserTrack.joined(chan, sender, [])
+ ExIRC.Client.who(state.client, chan) # Rewho everything in case of need ? We shouldn't not know that user..
+ user
+ end
if !user do
- Logger.error("Could not lookup user for message: #{inspect {state.network, sender.nick}}")
+ ExIRC.Client.who(state.client, chan) # Rewho everything in case of need ? We shouldn't not know that user..
+ Logger.error("Could not lookup user nor create it for message: #{inspect {state.network, chan, sender.nick}}")
else
if !Map.get(user.options, :puppet) do
reply_fun = fn(text) -> irc_reply(state, {chan, sender}, text) end