{"id":13507542,"url":"https://github.com/bitwalker/exirc","last_synced_at":"2025-04-13T02:16:41.051Z","repository":{"id":12322372,"uuid":"14958884","full_name":"bitwalker/exirc","owner":"bitwalker","description":"IRC client adapter for Elixir projects","archived":false,"fork":false,"pushed_at":"2024-07-28T17:30:49.000Z","size":283,"stargazers_count":155,"open_issues_count":8,"forks_count":37,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-13T02:16:36.163Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://bitwalker.github.io/exirc/","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitwalker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-05T16:22:16.000Z","updated_at":"2025-03-23T15:50:16.000Z","dependencies_parsed_at":"2024-05-01T16:19:35.711Z","dependency_job_id":"52263af8-d2dd-4a80-b566-68886a5ba244","html_url":"https://github.com/bitwalker/exirc","commit_stats":{"total_commits":223,"total_committers":24,"mean_commits":9.291666666666666,"dds":"0.34977578475336324","last_synced_commit":"65b6552cd2d2a7318554c7330e8e2ebff153615c"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwalker%2Fexirc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwalker%2Fexirc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwalker%2Fexirc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwalker%2Fexirc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitwalker","download_url":"https://codeload.github.com/bitwalker/exirc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654104,"owners_count":21140237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:35.931Z","updated_at":"2025-04-13T02:16:41.031Z","avatar_url":"https://github.com/bitwalker.png","language":"Elixir","readme":"# ExIRC\n\n[![Build Status](https://travis-ci.org/bitwalker/exirc.svg?branch=master)](https://travis-ci.org/bitwalker/exirc)\n![.github/workflows/tests.yaml](https://github.com/bitwalker/exirc/workflows/.github/workflows/tests.yaml/badge.svg)\n[![Hex.pm Version](http://img.shields.io/hexpm/v/exirc.svg?style=flat)](https://hex.pm/packages/exirc)\n\nExIRC is a IRC client library for Elixir projects. It aims to have a clear, well\ndocumented API, with the minimal amount of code necessary to allow you to connect and\ncommunicate with IRC servers effectively. It aims to implement the full RFC2812 protocol,\nand relevant parts of RFC1459.\n\n## Getting Started\n\nAdd ExIRC as a dependency to your project in mix.exs, and add it as an application:\n\n```elixir\n  defp deps do\n    [{:exirc, \"~\u003e x.x.x\"}]\n  end\n\n  defp application do\n    [applications: [:exirc],\n     ...]\n  end\n```\n\nThen fetch it using `mix deps.get`.\n\nTo use ExIRC, you need to start a new client process, and add event handlers. An example event handler module\nis located in `lib/exirc/example_handler.ex`. **The example handler is kept up to date with all events you can\nexpect to receive from the client**. A simple module is defined below as an example of how you might\nuse ExIRC in practice. ExampleHandler here is the one that comes bundled with ExIRC.\n\nThere is also a variety of examples in `examples`, the most up to date of which is `examples/bot`.\n\n```elixir\ndefmodule ExampleSupervisor do\n    defmodule State do\n        defstruct host: \"chat.freenode.net\",\n                  port: 6667,\n                  pass: \"\",\n                  nick: \"bitwalker\",\n                  user: \"bitwalker\",\n                  name: \"Paul Schoenfelder\",\n                  client: nil,\n                  handlers: []\n    end\n\n    def start_link(_) do\n        :gen_server.start_link(__MODULE__, [%State{}])\n    end\n\n    def init(state) do\n        # Start the client and handler processes, the ExIRC supervisor is automatically started when your app runs\n        {:ok, client}  = ExIRC.start_link!()\n        {:ok, handler} = ExampleHandler.start_link(nil)\n\n        # Register the event handler with ExIRC\n        ExIRC.Client.add_handler client, handler\n\n        # Connect and logon to a server, join a channel and send a simple message\n        ExIRC.Client.connect!   client, state.host, state.port\n        ExIRC.Client.logon      client, state.pass, state.nick, state.user, state.name\n        ExIRC.Client.join       client, \"#elixir-lang\"\n        ExIRC.Client.msg        client, :privmsg, \"#elixir-lang\", \"Hello world!\"\n\n        {:ok, %{state | :client =\u003e client, :handlers =\u003e [handler]}}\n    end\n\n    def terminate(_, state) do\n        # Quit the channel and close the underlying client connection when the process is terminating\n        ExIRC.Client.quit state.client, \"Goodbye, cruel world.\"\n        ExIRC.Client.stop! state.client\n        :ok\n    end\nend\n```\n\nA more robust example usage will wait until connected before it attempts to logon and then wait until logged\non until it attempts to join a channel. Please see the `examples` directory for more in-depth examples cases.\n\n```elixir\n\ndefmodule ExampleApplication do\n  use Application\n\n  # See https://hexdocs.pm/elixir/Application.html\n  # for more information on OTP Applications\n  @impl true\n  def start(_type, _args) do\n    {:ok, client} = ExIRC.start_link!\n\n    children = [\n      # Define workers and child supervisors to be supervised\n      {ExampleConnectionHandler, client},\n      # here's where we specify the channels to join:\n      {ExampleLoginHandler, [client, [\"#ohaibot-testing\"]]}\n    ]\n\n    # See https://hexdocs.pm/elixir/Supervisor.html\n    # for other strategies and supported options\n    opts = [strategy: :one_for_one, name: ExampleApplication.Supervisor]\n    Supervisor.start_link(children, opts)\n  end\nend\n\ndefmodule ExampleConnectionHandler do\n  defmodule State do\n    defstruct host: \"chat.freenode.net\",\n              port: 6667,\n              pass: \"\",\n              nick: \"bitwalker\",\n              user: \"bitwalker\",\n              name: \"Paul Schoenfelder\",\n              client: nil\n  end\n\n  def start_link(client, state \\\\ %State{}) do\n    GenServer.start_link(__MODULE__, [%{state | client: client}])\n  end\n\n  def init([state]) do\n    ExIRC.Client.add_handler state.client, self\n    ExIRC.Client.connect! state.client, state.host, state.port\n    {:ok, state}\n  end\n\n  def handle_info({:connected, server, port}, state) do\n    debug \"Connected to #{server}:#{port}\"\n    ExIRC.Client.logon state.client, state.pass, state.nick, state.user, state.name\n    {:noreply, state}\n  end\n\n  # Catch-all for messages you don't care about\n  def handle_info(msg, state) do\n    debug \"Received unknown messsage:\"\n    IO.inspect msg\n    {:noreply, state}\n  end\n\n  defp debug(msg) do\n    IO.puts IO.ANSI.yellow() \u003c\u003e msg \u003c\u003e IO.ANSI.reset()\n  end\nend\n\ndefmodule ExampleLoginHandler do\n  @moduledoc \"\"\"\n  This is an example event handler that listens for login events and then\n  joins the appropriate channels. We actually need this because we can't\n  join channels until we've waited for login to complete. We could just\n  attempt to sleep until login is complete, but that's just hacky. This\n  as an event handler is a far more elegant solution.\n  \"\"\"\n  def start_link(client, channels) do\n    GenServer.start_link(__MODULE__, [client, channels])\n  end\n\n  def init([client, channels]) do\n    ExIRC.Client.add_handler client, self\n    {:ok, {client, channels}}\n  end\n\n  def handle_info(:logged_in, state = {client, channels}) do\n    debug \"Logged in to server\"\n    channels |\u003e Enum.map(\u0026ExIRC.Client.join client, \u00261)\n    {:noreply, state}\n  end\n\n  # Catch-all for messages you don't care about\n  def handle_info(_msg, state) do\n    {:noreply, state}\n  end\n\n  defp debug(msg) do\n    IO.puts IO.ANSI.yellow() \u003c\u003e msg \u003c\u003e IO.ANSI.reset()\n  end\nend\n```\n\n## Projects using ExIRC (in the wild!)\n\nBelow is a list of projects that we know of (if we've missed anything,\nsend a PR!) that use ExIRC in the wild.\n\n- [Kuma][kuma] by @ryanwinchester\n- [Offension][offension] by @shymega\n- [hedwig_irc][hedwig_irc] by @jeffweiss\n- [Hekateros][hekateros] by @tchoutri\n\n[kuma]: https://github.com/ryanwinchester/kuma\n[offension]: https://github.com/shymega/offension\n[hedwig_irc]: https://github.com/jeffweiss/hedwig_irc\n[hekateros]: https://github.com/friendshipismagic/hekateros\n","funding_links":[],"categories":["Chatting","Networking"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwalker%2Fexirc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitwalker%2Fexirc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwalker%2Fexirc/lists"}