-- The message handler
onMessage :: IRCConnection -> String -> String -> String -> IO ()
onMessage conn chan nick msg = do
  let url = matchRegex (mkRegex "(https?://[^ \r\n$]+)") msg
  case url of
    Nothing     -> return ()
    Just [url]  -> do (code, text) <- curlGetString url [CurlFollowLocation True]
                      let title = matchRegex (mkRegex "<[tT][iI][tT][lL][eE].*?>\\s*(.*?)\\s*<\\/[tT][iI][tT][lL][eE]") text
                      case title of
                        Nothing      -> return ()
                        Just [title] -> sendMessage conn chan title
onMessage :: IRCConnection -> String -> String -> String -> IO ()
onMessage conn chan nick msg = do
  let url = matchRegex (mkRegex "(https?://[^ \r\n$]+)") msg
  case url of
    Nothing     -> return ()
    Just [url]  -> do (code, text) <- curlGetString url [CurlFollowLocation True]
                      let title = matchRegex (mkRegex "<[tT][iI][tT][lL][eE].*?>\\s*(.*?)\\s*<\\/[tT][iI][tT][lL][eE]") text
                      case title of
                        Nothing      -> return ()
                        Just [title] -> sendMessage conn chan title
onMessage conn chan nick msg = do
  let url = matchRegex (mkRegex "(https?://[^ \r\n$]+)") msg
  case url of
    Nothing     -> return ()
    Just [url]  -> do (code, text) <- curlGetString url [CurlFollowLocation True]
                      let title = matchRegex (mkRegex "<[tT][iI][tT][lL][eE].*?>\\s*(.*?)\\s*<\\/[tT][iI][tT][lL][eE]") text
                      case title of
                        Nothing      -> return ()
                        Just [title] -> sendMessage conn chan title