summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorPaul Schoenfelder <paulschoenfelder@gmail.com>2013-12-09 18:41:46 -0600
committerPaul Schoenfelder <paulschoenfelder@gmail.com>2013-12-09 18:41:46 -0600
commitf2358389bba6fafc859f3087cfffd7032b3e5d64 (patch)
tree4aaebf6c3950303312af3e5213889642ffe3696d /README.md
parentAdd exdoc dependency, and metadata (diff)
Add getting started info to README
Diffstat (limited to 'README.md')
-rw-r--r--README.md61
1 files changed, 59 insertions, 2 deletions
diff --git a/README.md b/README.md
index 9855cd2..a4ea7e4 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-# exirc
+# ExIrc
-ExIRC is a IRC client library for Elixir projects. It aims to have a clear, well
+ExIrc is a IRC client library for Elixir projects. It aims to have a clear, well
documented API, with the minimal amount of code necessary to allow you to connect and
communicate with IRC servers effectively. It aims to implement the full RFC2812 protocol,
and relevant parts of RFC1459.
@@ -15,3 +15,60 @@ with.
Alpha. The API is complete and everything is implemented, but little testing has been done (I've tested the API against my own local IRC server, but nothing robust enough to call this production ready). Any bugs you find, please report them in the issue tracker and I'll address them as soon as possible. If you have any questions, or if the documentation seems incomplete, let me know and I'll fill it in.
+## Getting Started
+
+Add ExIrc as a dependency to your project in mix.exs:
+
+```elixir
+ defp deps do
+ [{:exirc, github: "bitwalker/exirc"}]
+ end
+```
+
+Then fetch it using `mix deps.get`.
+
+To use ExIrc, you need to start a new client process, and add event handlers. An example event handler module
+is located in `lib/exirc/example_handler.ex`. A simple module is defined below as an example of how you might
+use ExIrc in practice. ExampleHandler here is the one that comes bundled with ExIrc.
+
+```elixir
+defmodule ExampleSupervisor do
+ defrecord State,
+ host: "chat.freenode.net",
+ port: 6667,
+ pass: "",
+ nick: "bitwalker",
+ user: "bitwalker",
+ name: "Paul Schoenfelder",
+ client: nil,
+ handlers: []
+
+ def start_link(_) do
+ :gen_server.start_link(__MODULE__, [State.new()])
+ end
+
+ def init([state]) do
+ # Start the client and handler processes
+ {:ok, client} = ExIrc.Client.start!()
+ {:ok, handler} = ExampleHandler.start_link(nil)
+
+ # Register the event handler with ExIrc
+ ExIrc.Client.add_handler handler
+
+ # Connect and logon to a server, join a channel and send a simple message
+ ExIrc.Client.connect! client, state.host, state.port
+ ExIrc.Client.logon client, state.pass, state.nick, state.user, state.name
+ ExIrc.Client.join client, "#elixir-lang"
+ ExIrc.Client.msg client, :privmsg, "#elixir-lang", "Hello world!"
+
+ {:ok, state.client(client).handlers([handler])}
+ end
+
+ def terminate(_, state) do
+ # Quit the channel and close the underlying client connection when the process is terminating
+ ExIrc.Client.quit state.client, "Goodbye, cruel world."
+ ExIrc.Client.stop! state.client
+ :ok
+ end
+end
+```