-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathirc_client.mli
116 lines (98 loc) · 4 KB
/
irc_client.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
(** Generic IRC client library, functorised over the
{{:Irc_transport.IO.html}Irc_transport.IO} module. *)
module type CLIENT = sig
module Io : sig
type 'a t
type inet_addr
type config
end
type connection_t
val send : connection:connection_t -> Irc_message.t -> unit Io.t
(** Send the given message *)
val send_join : connection:connection_t -> channel:string -> unit Io.t
(** Send the JOIN command. *)
val send_nick : connection:connection_t -> nick:string -> unit Io.t
(** Send the NICK command. *)
val send_pass : connection:connection_t -> password:string -> unit Io.t
(** Send the PASS command. *)
val send_pong : connection:connection_t ->
message1:string -> message2:string -> unit Io.t
(** Send the PONG command. *)
val send_privmsg : connection:connection_t ->
target:string -> message:string -> unit Io.t
(** Send the PRIVMSG command. *)
val send_notice : connection:connection_t ->
target:string -> message:string -> unit Io.t
(** Send the NOTICE command. *)
val send_quit : ?msg:string -> connection:connection_t -> unit -> unit Io.t
(** Send the QUIT command. *)
val send_user : connection:connection_t ->
username:string -> mode:int -> realname:string -> unit Io.t
(** Send the USER command. *)
val connect :
?username:string -> ?mode:int -> ?realname:string -> ?password:string ->
?sasl:bool -> ?config:Io.config ->
addr:Io.inet_addr -> port:int -> nick:string -> unit ->
connection_t Io.t
(** Connect to an IRC server at address [addr]. The PASS command will be
sent if [password] is not None and if [sasl] is [false].
@param sasl if true, try to use SASL (plain) authentication with the server.
This is an IRCv3 extension and might not be supported everywhere; it
might also require a secure transport (see {!Irc_client_lwt_ssl}
or {!Irc_client_tls} for example). This param exists @since 0.7.
*)
val connect_by_name :
?username:string -> ?mode:int -> ?realname:string -> ?password:string ->
?sasl:bool -> ?config:Io.config ->
server:string -> port:int -> nick:string -> unit ->
connection_t option Io.t
(** Try to resolve the [server] name using DNS, otherwise behaves like
{!connect}. Returns [None] if no IP could be found for the given
name. See {!connect} for more details. *)
(** Information on keeping the connection alive *)
type keepalive = {
mode: [`Active | `Passive];
timeout: int;
}
val default_keepalive : keepalive
(** Default value for keepalive: active mode with auto-reconnect *)
val listen :
?keepalive:keepalive ->
connection:connection_t ->
callback:(
connection_t ->
Irc_message.parse_result ->
unit Io.t) ->
unit ->
unit Io.t
(** [listen connection callback] listens for incoming messages on
[connection]. All server pings are handled internally; all other
messages are passed, along with [connection], to [callback].
@param keepalive the behavior on disconnection (if the transport
supports {!Irc_transport.IO.pick} and {!Irc_transport.IO.sleep}) *)
val reconnect_loop :
?keepalive:keepalive ->
?reconnect:bool ->
after:int ->
connect:(unit -> connection_t option Io.t) ->
f:(connection_t -> unit Io.t) ->
callback:(
connection_t ->
Irc_message.parse_result ->
unit Io.t) ->
unit ->
unit Io.t
(** A combination of {!connect} and {!listen} that, every time
the connection is terminated, tries to start a new one
after [after] seconds. It stops reconnecting if the exception
[Exit] is raised.
@param after time before trying to reconnect
@param connect how to reconnect
(a closure over {!connect} or {!connect_by_name})
@param callback the callback for {!listen}
@param f the function to call after connection *)
end
module Make : functor (Io: Irc_transport.IO) ->
CLIENT with type 'a Io.t = 'a Io.t
and type Io.inet_addr = Io.inet_addr
and type Io.config = Io.config