1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
|