From 919725a6941830ce82c835ed3288c1722ddd8c9f Mon Sep 17 00:00:00 2001 From: href Date: Fri, 17 Apr 2020 15:53:14 +0200 Subject: bleh --- lib/irc/pubsub_handler.ex | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/irc/pubsub_handler.ex') diff --git a/lib/irc/pubsub_handler.ex b/lib/irc/pubsub_handler.ex index 450dc2f..61ae55c 100644 --- a/lib/irc/pubsub_handler.ex +++ b/lib/irc/pubsub_handler.ex @@ -23,6 +23,10 @@ defmodule IRC.PubSubHandler do GenServer.start_link(__MODULE__, [client], [name: __MODULE__]) end + def privmsg(channel, line) do + GenServer.cast(__MODULE__, {:privmsg, channel, line}) + end + def init([client]) do ExIRC.Client.add_handler(client, self()) {:ok, client} @@ -37,6 +41,11 @@ defmodule IRC.PubSubHandler do "~" => :tilde } + def handle_cast({:privmsg, channel, line}, client) do + irc_reply(client, {channel, nil}, line) + {:noreply, client} + end + def handle_info({:received, text, sender, chan}, client) do reply_fun = fn(text) -> irc_reply(client, {chan, sender}, text) end message = %IRC.Message{text: text, sender: sender, channel: chan, replyfun: reply_fun, trigger: extract_trigger(text)} -- cgit v1.2.3