package irc-client

  1. Overview
  2. Docs

Module Irc_messageSource

IRC message parsing.

Sourcetype command =
  1. | PASS of string
  2. | NICK of string
  3. | USER of string list
    (*

    see rfc

    *)
  4. | OPER of string * string
    (*

    name * password

    *)
  5. | MODE of string * string
    (*

    nick * mode string

    *)
  6. | QUIT of string
    (*

    quit message

    *)
  7. | SQUIT of string * string
    (*

    server * comment

    *)
  8. | JOIN of string list * string list
    (*

    channels * key list

    *)
  9. | JOIN0
    (*

    join 0 (parts all channels)

    *)
  10. | PART of string list * string
    (*

    channels * comment

    *)
  11. | TOPIC of string * string
    (*

    chan * topic

    *)
  12. | NAMES of string list
    (*

    channels

    *)
  13. | LIST of string list
    (*

    channels

    *)
  14. | INVITE of string * string
    (*

    nick * chan

    *)
  15. | KICK of string list * string * string
    (*

    channels * nick * comment

    *)
  16. | PRIVMSG of string * string
    (*

    target * message

    *)
  17. | NOTICE of string * string
    (*

    target * message

    *)
  18. | PING of string * string
  19. | PONG of string * string
  20. | Other of string * string list
    (*

    other cases

    *)

A type representing an IRC command, following RFC 2812

Sourcetype t = {
  1. prefix : string option;
  2. command : command;
}

Constructors

Sourceval pass : string -> t
Sourceval nick : string -> t
Sourceval user : username:string -> mode:int -> realname:string -> t
Sourceval oper : name:string -> pass:string -> t
Sourceval mode : nick:string -> mode:string -> t
Sourceval quit : msg:string option -> t
Sourceval join : chans:string list -> keys:string list option -> t
Sourceval join0 : t
Sourceval part : chans:string list -> comment:string option -> t
Sourceval topic : chan:string -> topic:string option -> t
Sourceval names : chans:string list -> t
Sourceval list : chans:string list -> t
Sourceval invite : nick:string -> chan:string -> t
Sourceval kick : chans:string list -> nick:string -> comment:string option -> t
Sourceval privmsg : target:string -> string -> t
Sourceval notice : target:string -> string -> t
Sourceval ping : message1:string -> message2:string -> t
Sourceval pong : message1:string -> message2:string -> t
Sourceval other : cmd:string -> params:string list -> t

Printing

Sourceval to_string : t -> string

Format the message into a string that can be sent on IRC

Sourceval output : out_channel -> t -> unit
Sourceval write_buf : Buffer.t -> t -> unit

Parsing

Sourcetype 'a or_error = ('a, string) Result.result
Sourcetype parse_result = t or_error
Sourceexception ParseError of string * string
Sourceval parse : string -> t or_error

Attempt to parse an IRC message.

Sourceval parse_exn : string -> t

parse_exn s returns the parsed message

  • raises ParseError

    if the string is not a proper message

Low level Functions -- testing

Sourceval extract_prefix : string -> string option * string

Exposed for testing - not intended for use.

Sourceval extract_trail : string -> string * string option

Exposed for testing - not intended for use.

OCaml

Innovation. Community. Security.