X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FMain.hs;h=fc7966f9f1df518283cae1ce2705b1e1effb058e;hb=85aa472950924557e80b793303d9b6dee0261c7c;hp=f6fd170ed1c2073827e33522b675747581b9af83;hpb=5f1220bd5d1b6893a4e2c0a179b3244a12eae6c8;p=dead%2Fhalcyon.git diff --git a/src/Main.hs b/src/Main.hs index f6fd170..fc7966f 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -154,3 +154,34 @@ main = do thread_sleep heartbeat return () + + +-- |A debugging tool that will parse, print, and email a single status +-- (given by its id). +twat_single_status :: Integer -> (Maybe Message) -> IO () +twat_single_status the_status_id maybe_message = do + xmldata <- get_status the_status_id + + -- Parsing an empty result can blow up. Just pretend there are + -- no new statuses in that case. + let statuses = case xmldata of + Just xml -> parse_status xml + Nothing -> [] + + case (length statuses) of + 0 -> do + putStrLn "No statuses returned." + return () + _ -> do + _ <- mapM (putStrLn . pretty_print) statuses + + case maybe_message of + Nothing -> do + putStrLn "No message object given." + return () + Just message -> do + date_header <- construct_date_header + let messages = map (message_from_status message (date_header)) statuses + sendmail_results <- mapM sendmail messages + _ <- mapM print_sendmail_result sendmail_results + return ()