cheesebot/ocaml/evaluate.ml
Fabien Freling 764581f505 Add Evaluate module.
The Evaluate module contains the logic for cheesebot actions.
2014-03-14 23:02:27 +01:00

21 lines
485 B
OCaml

open Str
let is_url url =
let regexp = regexp "\\(https?\\://\\)?www\\..+\\..+" in
string_match regexp url 0
let is_youtube_url url =
let regexp = regexp "\\(https?\\://\\)?\\(www\\.\\)?\\(youtube\\.com\\)\\|\\(youtu\\.be\\)/.+" in
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_url str ->
SimpleHttp.get_http_title (SimpleHttp.get_body str)
| _ -> None