summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/base_handler.ex
diff options
context:
space:
mode:
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
+