cheesebot/ocaml/main.ml
Fabien Freling a3488cb554 Use regexp to check if youtube url.
- Add basic build command.
2013-12-08 17:07:53 +01:00

26 lines
539 B
OCaml

open Http_client
open Str
(* Regexp required here *)
let is_youtube_url url =
let regexp = Str.regexp "http://www.youtube.com/.+" in
Str.string_match regexp url 0;;
(* Maybe have a list of functions and
* iter on all the items in the list *)
let evaluate str =
match str with
| str when is_youtube_url str -> "that's youtube"
| _ -> str;;
try
while true do
print_string "> ";
let line = read_line () in
let answer = evaluate line in
print_endline answer
done
with
End_of_file -> print_endline "Bye!";;