talircd/lib/irc/mode.mli

101 lines
2.1 KiB
OCaml

open Types
(*
User Modes:
+i Invisible User Mode
+o Oper User Mode
+w WALLOPS User Mode
Channel Modes:
Type A:
+b Ban Channel Mode
Type B:
+k Key Channel Mode
+o Operator Channel Membership Prefix (@)
+v Voice Channel Membership Prefix (+)
Type C:
+l Client Limit Channel Mode
Type D:
+i Invite-Only Channel Mode
+m Moderated Channel Mode
+n No External Messages Mode
+s Secret Channel Mode
+t Protected Topic Channel Mode
*)
type user = [`i | `o | `w]
type chan_a = [`b]
type chan_b = [`k | `o | `v]
type chan_c = [`l]
type chan_d = [`i | `m | `s | `t | `n]
type chan = [chan_a | chan_b | chan_c | chan_d]
type t = [user | chan]
val pp : Format.formatter -> [< t] -> unit
val to_char : [< t] -> char
val of_char_user : char -> [> user]
val of_char_chan : char -> [> chan]
module Set : sig
type t
type elt = [user | chan_d]
val empty : t
val singleton : [< elt] -> t
val mem : [< elt] -> t -> bool
val add : [< elt] -> t -> t
val remove : [< elt] -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val equal : t -> t -> bool
val pp : Format.formatter -> t -> unit
val to_string : t -> string
val of_string : string -> t
val of_list : [< elt] list -> t
(* val to_list : t -> elt list *)
type change = {
add : t;
rem : t;
}
val pp_change : Format.formatter -> change -> unit
val no_change : change
val normalize : t -> change -> t * change
end
module Parse : sig
exception Unknown_mode of char
exception Missing_args
type user_modes = Set.change
type 'a set_or_unset = [
| `set of 'a
| `unset
]
type add_or_rem = [
| `add
| `rem
]
type priv = [`o | `v]
type chan_modes = {
chan_modes : Set.change;
chan_key : string set_or_unset option;
chan_limit : int set_or_unset option;
chan_privs : (add_or_rem * priv * name) list;
}
val user_modes : string -> user_modes
val chan_modes : string -> string list -> chan_modes
end