summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/base_handler.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2018-02-17 21:21:42 +0100
committerhref <href@random.sh>2018-02-17 21:21:42 +0100
commit50c6a09ff64cb081b27a0c30790b86873449d172 (patch)
treeba1bebfc7e367f169276692e0ac02709d62d6516 /lib/lsg_irc/base_handler.ex
parenttxt: fix against malicious filenames (aka 'fuck you shiv') (diff)
:)
Diffstat (limited to 'lib/lsg_irc/base_handler.ex')
-rw-r--r--lib/lsg_irc/base_handler.ex37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/lsg_irc/base_handler.ex b/lib/lsg_irc/base_handler.ex
new file mode 100644
index 0000000..9145936
--- /dev/null
+++ b/lib/lsg_irc/base_handler.ex
@@ -0,0 +1,37 @@
+defmodule LSG.IRC.BaseHandler do
+
+ use LSG.IRC.Handler
+
+ def irc_doc, do: nil
+
+ def start_link(client) do
+ GenServer.start_link(__MODULE__, [client])
+ end
+
+ def init([client]) do
+ ExIRC.Client.add_handler client, self
+ {:ok, client}
+ end
+
+ def handle_info({:received, "!help", %ExIRC.SenderInfo{nick: nick}, chan}, client) do
+ url = LSGWeb.Router.Helpers.irc_url(LSGWeb.Endpoint, :index)
+ ExIRC.Client.msg(client, :privmsg, chan, "#{nick}: #{url}")
+ {:noreply, client}
+ end
+
+ def handle_info({:received, "version", %ExIRC.SenderInfo{nick: nick}}, client) do
+ {:ok, vsn} = :application.get_key(:lsg, :vsn)
+ ver = List.to_string(vsn)
+ url = LSGWeb.Router.Helpers.irc_url(LSGWeb.Endpoint, :index)
+ version = "v#{ver} ; #{url} ; source: https://git.yt/115ans/sys"
+ ExIRC.Client.msg(client, :privmsg, nick, version)
+ {:noreply, client}
+ end
+
+ def handle_info(msg, client) do
+ IO.inspect(msg)
+ {:noreply, client}
+ end
+
+end
+