diff options
Diffstat (limited to 'lib/lsg_irc/calc_handler.ex')
-rw-r--r-- | lib/lsg_irc/calc_handler.ex | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/lib/lsg_irc/calc_handler.ex b/lib/lsg_irc/calc_handler.ex deleted file mode 100644 index 0f74ac9..0000000 --- a/lib/lsg_irc/calc_handler.ex +++ /dev/null @@ -1,38 +0,0 @@ -defmodule LSG.IRC.CalcHandler do - @moduledoc """ - # calc - - * **!calc `<expression>`**: évalue l'expression mathématique `<expression>`. - """ - - def irc_doc, do: @moduledoc - - 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, "!calc "<>expr, %ExIRC.SenderInfo{nick: nick}, chan}, client) do - IO.inspect "HAZ CALC " <>inspect(expr) - result = try do - case Abacus.eval(expr) do - {:ok, result} -> result - error -> inspect(error) - end - rescue - error -> "#{error.message}" - end - ExIRC.Client.msg(client, :privmsg, chan, "#{nick}: #{expr} = #{result}") - {:noreply, client} - end - - def handle_info(msg, client) do - {:noreply, client} - end - -end - |