From a28d24470ddeca6196219a1333c1ccac1319efef Mon Sep 17 00:00:00 2001 From: href Date: Wed, 11 Mar 2020 21:18:34 +0100 Subject: welp --- lib/irc/pubsub_handler.ex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/irc') diff --git a/lib/irc/pubsub_handler.ex b/lib/irc/pubsub_handler.ex index 3e78d7b..450dc2f 100644 --- a/lib/irc/pubsub_handler.ex +++ b/lib/irc/pubsub_handler.ex @@ -6,7 +6,7 @@ defmodule IRC.PubSubHandler do ## PubSub topics - * `message` -- all messages (including triggers) + * `message` -- all messages (without triggers) * `message:private` -- all messages without a channel * `message:#CHANNEL` -- all messages within `#CHANNEL` * `triggers` -- all triggers @@ -34,6 +34,7 @@ defmodule IRC.PubSubHandler do "-" => :minus, "?" => :query, "." => :dot, + "~" => :tilde } def handle_info({:received, text, sender, chan}, client) do @@ -62,7 +63,7 @@ defmodule IRC.PubSubHandler do end defp publish(m = %IRC.Message{trigger: t = %IRC.Trigger{trigger: trigger}}, keys) do - dispatch(["message", "triggers", "trigger:"<>trigger]++keys, {:irc, :trigger, trigger, m}) + dispatch(["triggers", "trigger:"<>trigger], {:irc, :trigger, trigger, m}) end defp dispatch(key, content) when is_binary(key), do: dispatch([key], content) @@ -96,8 +97,10 @@ defmodule IRC.PubSubHandler do # irc_reply(ExIRC.Client pid, {channel or nick, ExIRC.Sender}, binary | replies # replies :: {:kick, reason} | {:kick, nick, reason} | {:mode, mode, nick} - defp irc_reply(client, {target, _}, text) when is_binary(text) do - ExIRC.Client.msg(client, :privmsg, target, text) + defp irc_reply(client, {target, _}, text) when is_binary(text) or is_list(text) do + for line <- IRC.splitlong(text) do + ExIRC.Client.msg(client, :privmsg, target, line) + end end defp irc_reply(client, {target, %{nick: nick}}, {:kick, reason}) do -- cgit v1.2.3