X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhalcyon.git;a=blobdiff_plain;f=src%2FMain.hs;h=de209899bfedfb9611b269e21e8693b00f4aa79b;hp=f42f2ce57738a4899005d146bf0700b46c88a377;hb=376e4ed1f16a0fe5a4d100877c618d85e20a9b8f;hpb=69b8af30f49aaad0f5c051998d2556b9ec291df7 diff --git a/src/Main.hs b/src/Main.hs index f42f2ce..de20989 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -26,13 +26,14 @@ thread_sleep seconds = do threadDelay microseconds --- |Given a 'Message' and a 'Status', update that message's body and --- subject with the information contained in the status. Returns the --- updated message. -message_from_status :: Message -> Status -> Message -message_from_status message status = +-- |Given a 'Message', 'Status', and date, update that message's body +-- and subject with the information contained in the status. Adds a +-- /Date: / header, and returns the updated message. +message_from_status :: Message -> String -> Status -> Message +message_from_status message date status = message { subject = "Twat: " ++ (screen_name (user status)), - body = (pretty_print status) } + body = (pretty_print status), + headers = ((headers message) ++ ["Date: " ++ date])} -- |This is the main recursive loop. It takes a username, a @@ -64,7 +65,8 @@ recurse username latest_status_id maybe_message = do recurse username new_latest_status_id maybe_message return () Just message -> do - let messages = map (message_from_status message) new_statuses + date_header <- construct_date_header + let messages = map (message_from_status message (date_header)) new_statuses sendmail_results <- mapM sendmail messages mapM print_sendmail_result sendmail_results recurse username new_latest_status_id maybe_message @@ -136,7 +138,7 @@ main = do case from_address of Nothing -> Nothing Just fromaddr -> - Just (Message { headers = [], + Just (Message { headers = default_headers, body = "", subject = "", to = toaddr,