recurse :: Cfg -> String -> Integer -> (Maybe Message) -> IO ()
recurse cfg username latest_status_id maybe_message = do
thread_sleep (heartbeat cfg)
- timeline <- get_user_new_statuses username latest_status_id
+ timeline <- get_user_new_statuses cfg username latest_status_id
-- FIXME
let Just new_statuses = decode timeline :: Maybe Timeline
-- | Try continually to download username's timeline, and determine the
-- latest status id to be posted once we have done so.
-get_latest_status_id :: Int -> String -> IO Integer
-get_latest_status_id delay username = do
- timeline <- get_user_timeline username
+get_latest_status_id :: Cfg -> String -> IO Integer
+get_latest_status_id cfg username = do
+ let delay = heartbeat cfg
+ timeline <- get_user_timeline cfg username
let Just initial_timeline = decode timeline :: Maybe Timeline
case (length initial_timeline) of
-- If the HTTP part barfs, try again after a while.
putStrLn ("Couldn't retrieve " ++ username ++ "'s timeline. Retrying...")
thread_sleep delay
- get_latest_status_id delay username
+ get_latest_status_id cfg username
_ -> return (get_max_status_id initial_timeline)
-- should be emailed.
run_twat :: Cfg -> Maybe Message -> String -> IO ()
run_twat cfg msg username = do
- latest_status_id <- get_latest_status_id (heartbeat cfg) username
+ latest_status_id <- get_latest_status_id cfg username
recurse cfg username latest_status_id msg
return ()
-- And a Cfg object.
cfg <- get_cfg
-
+
-- If we have both a "To" and "From" address, we'll create a
-- message object to be passed to all of our threads.
let message = construct_message cfg