Skip to content
OCaml IRC client library
OCaml Makefile
Branch: master
Clone or download
johnelse Merge pull request #50 from c-cube/wip-opam2
use opam2 + travis-docker
Latest commit a79fc63 Sep 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples feat: add support for lwt_ssl Sep 15, 2019
src feat: add support for lwt_ssl Sep 15, 2019
test
.gitignore Remove some oasis things from .gitignore Apr 24, 2018
.travis.yml fix travis Sep 18, 2019
ChangeLog Release 0.6.1 Aug 1, 2018
LICENSE
MAINTAINERS Fix maintainer email Oct 14, 2016
Makefile
README.md Remove dead code from examples Jul 24, 2018
dune-project switch to dune Dec 12, 2018
irc-client-lwt-ssl.opam
irc-client-lwt.opam
irc-client-tls.opam chore: use opam2 description files Sep 18, 2019
irc-client-unix.opam chore: use opam2 description files Sep 18, 2019
irc-client.opam chore: use opam2 description files Sep 18, 2019

README.md

IRC client library, supporting Lwt and Unix blocking IO.

Build status Coverage Status API reference

Build dependencies

The latest tagged version is available via opam: opam install irc-client

Usage

Simple bot which connects to a channel, sends a message, and then logs all messages in that channel to stdout:

open Lwt
module C = Irc_client_lwt

let host = "localhost"
let port = 6667
let realname = "Demo IRC bot"
let nick = "demoirc"
let username = nick
let channel = "#demo_irc"
let message = "Hello, world!  This is a test from ocaml-irc-client"

let callback _connection result =
  let open Irc_message in
  match result with
  | Result.Ok msg ->
    Lwt_io.printf "Got message: %s\n" (to_string msg)
  | Result.Error e ->
    Lwt_io.printl e

let lwt_main =
  Lwt_unix.gethostbyname host
  >>= fun he -> C.connect ~addr:(he.Lwt_unix.h_addr_list.(0))
                  ~port ~username ~mode:0 ~realname ~nick ()
  >>= fun connection -> Lwt_io.printl "Connected"
  >>= fun () -> C.send_join ~connection ~channel
  >>= fun () -> C.send_privmsg ~connection ~target:channel ~message
  >>= fun () -> C.listen ~connection ~callback ()
  >>= fun () -> C.send_quit ~connection

let _ = Lwt_main.run lwt_main

Compile the above with:

ocamlfind ocamlopt -package irc-client.lwt -linkpkg code.ml

Alternatively, you can find it at examples/example1.ml; enable its compilation with ./configure --enable-examples --enable-lwt.

You can’t perform that action at this time.