defmodule LSG.IRC.BaseHandler do
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