summaryrefslogtreecommitdiff
path: root/lib/irc/puppet_connection.ex
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2023-03-06 18:09:57 +0100
committerJordan Bracco <href@random.sh>2023-03-06 18:09:57 +0100
commit5ab36499520e3dd9958c79b5c124333f1313ec5f (patch)
tree5b2d1dc806e401b31b2de3d4ef7752e3635e6fc8 /lib/irc/puppet_connection.ex
parentplugin: link/image: commit py node (diff)
hate this
Diffstat (limited to '')
-rw-r--r--lib/irc/puppet_connection.ex16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/irc/puppet_connection.ex b/lib/irc/puppet_connection.ex
index f5e2e5c..51b4c8a 100644
--- a/lib/irc/puppet_connection.ex
+++ b/lib/irc/puppet_connection.ex
@@ -35,11 +35,11 @@ defmodule Nola.Irc.PuppetConnection do
end
end
- 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})
+ def send_message(account = %Nola.Account{id: account_id}, connection = %Nola.Irc.Connection{id: connection_id}, channel, text, meta) do
+ GenServer.cast(name(account_id, connection_id), {:send_message, self(), channel, text, meta})
end
- def start_and_send_message(account = %Nola.Account{id: account_id}, connection = %Nola.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, meta) do
{:global, name} = name(account_id, connection_id)
pid = whereis(account, connection)
pid = if !pid do
@@ -50,7 +50,7 @@ defmodule Nola.Irc.PuppetConnection do
else
pid
end
- GenServer.cast(pid, {:send_message, self(), channel, text})
+ GenServer.cast(pid, {:send_message, self(), channel, text, meta})
end
def start(account = %Nola.Account{}, connection = %Nola.Irc.Connection{}) do
@@ -132,11 +132,11 @@ defmodule Nola.Irc.PuppetConnection do
{:noreply, %{state | buffer: []}}
end
- def handle_cast(cast = {:send_message, _pid, _channel, _text}, state = %{connected: false, buffer: buffer}) do
+ def handle_cast(cast = {:send_message, _pid, _channel, _text, _meta}, state = %{connected: false, buffer: buffer}) do
{:noreply, %{state | buffer: [cast | buffer]}}
end
- def handle_cast({:send_message, pid, channel, text}, state = %{connected: true}) do
+ def handle_cast({:send_message, pid, channel, text, pub_meta}, state = %{connected: true}) do
channels = if !Enum.member?(state.channels, channel) do
ExIRC.Client.join(state.client, channel)
[channel | state.channels]
@@ -145,12 +145,12 @@ defmodule Nola.Irc.PuppetConnection do
end
ExIRC.Client.msg(state.client, :privmsg, channel, text)
- meta = %{puppet: true, from: pid}
+ meta = %{puppet: true, from: pid, origin: Keyword.get(pub_meta, :origin, __MODULE__)}
account = Nola.Account.get(state.account_id)
nick = make_nick(state)
sender = %ExIRC.SenderInfo{network: state.network, nick: suffix_nick(nick), user: nick, host: "puppet."}
reply_fun = fn(text) ->
- Nola.Irc.Connection.broadcast_message(state.network, channel, text)
+ Nola.Irc.Connection.broadcast_message(state.network, channel, text, pub_meta)
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: Nola.Irc.Connection.extract_trigger(text), meta: meta}
message = case Nola.UserTrack.messaged(message) do