package irc-client

  1. Overview
  2. Docs
IRC client library - core functionality

Install

Dune Dependency

Authors

Maintainers

Sources

irc-client.0.6.0.tar.gz
sha256=049a80e15c3dfce35b3c88046a574a4dc85c6b45235df371dc129f6e1ef8ba5e
md5=06df0efe53238af79419c5633c2126f7

Description

Published: 21 Jun 2018

README

README.md

IRC client library, supporting Lwt and Unix blocking IO.

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 string_opt_to_string = function
  | None -> "None"
  | Some s -> Printf.sprintf "Some %s" s

let string_list_to_string string_list =
  Printf.sprintf "[%s]" (String.concat "; " string_list)

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.

Dependencies (4)

  1. result
  2. base-bytes
  3. jbuilder >= "1.0+beta7"
  4. ocaml >= "4.02.0"

Dev Dependencies (1)

  1. ounit with-test

Used by (5)

  1. calculon >= "0.3" & < "0.7"
  2. irc-client-lwt < "0.7.0"
  3. irc-client-lwt-ssl < "0.7.0"
  4. irc-client-tls < "0.7.0"
  5. irc-client-unix < "0.7.0"

Conflicts

None

OCaml

Innovation. Community. Security.