From: Michael Orlitzky Date: Fri, 1 Oct 2010 01:36:34 +0000 (-0400) Subject: Add a "Date: " header to outgoing messages. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=76af720585a173aa47e7858964b581fdbf7a01e6;p=dead%2Fhalcyon.git Add a "Date: " header to outgoing messages. --- diff --git a/src/Main.hs b/src/Main.hs index f42f2ce..53c3f90 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -4,6 +4,7 @@ where import Control.Concurrent (forkIO, threadDelay) import Control.Monad (forever, when) import System.Exit (ExitCode(..), exitWith) +import System.Time (getClockTime) import System.IO (hPutStrLn, stderr) import CommandLine @@ -26,13 +27,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 +66,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 <- getClockTime + let messages = map (message_from_status message (show date)) new_statuses sendmail_results <- mapM sendmail messages mapM print_sendmail_result sendmail_results recurse username new_latest_status_id maybe_message