summaryrefslogtreecommitdiff
path: root/lib/irc/client.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irc/client.ex')
-rw-r--r--lib/irc/client.ex48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/irc/client.ex b/lib/irc/client.ex
new file mode 100644
index 0000000..1c4b0c5
--- /dev/null
+++ b/lib/irc/client.ex
@@ -0,0 +1,48 @@
+defmodule Irc.Client do
+ alias Irc.BaseClient
+ @behaviour Irc.BaseClient
+ require Logger
+
+ @moduledoc """
+ Fully-featured IRC client.
+
+ The client uses message passing.
+
+ """
+
+ @type message :: Irc.BaseClient.event
+ @type start_ret :: BaseClient.start_ret
+
+ @spec start(Irc.Connection.nick, Irc.Connection.host, [BaseClient.start_opt], [:gen_statem.start_opt]) :: start_ret
+ def start(nick, host, opts \\ [], start_opts \\ []) do
+ :gen_statem.start(__MODULE__, [nick, host, prepare_args(opts)], start_opts)
+ end
+
+ @spec start_link(Irc.Connection.nick, Irc.Connection.host, [BaseClient.start_opt], [:gen_statem.start_opt]) :: start_ret
+ def start_link(nick, host, opts \\ [], start_opts \\ []) do
+ :gen_statem.start_link(__MODULE__, [nick, host, prepare_args(opts)], start_opts)
+ end
+
+ @doc false
+ def init(_) do
+ Logger.debug("CLIENT initiated")
+ {:ok, %{process: nil}}
+ end
+
+ @doc false
+ def handle_event(event, state) do
+ Logger.debug("CLIENT EVENT: #{inspect event}")
+ :ok
+ end
+
+ @doc false
+ def stop(reason, state) do
+ Logger.debug("CLIENT: Stopping, #{inspect reason}")
+ end
+
+ defp prepare_args(opts) do
+ opts
+ |> Keyword.put_new(:module, __MODULE__)
+ end
+end
+