irc-bot/plugin.ml

25 lines
474 B
OCaml
Raw Normal View History

2009-11-08 22:18:18 -07:00
type handler = Iobuf.t -> Command.t -> unit
let handlers = ref []
let register handler =
handlers := !handlers @ [handler]
let unregister handler =
handlers := List.filter ((<>) handler) !handlers
let handle_command iobuf cmd =
let rec loop h =
match h with
| [] -> ()
| handler :: tl ->
begin
try
handler iobuf cmd
with _ ->
()
end;
loop tl
in
loop !handlers