import Data.Aeson (decode)
import Data.List ((\\))
import Data.Time.LocalTime (TimeZone, getCurrentTimeZone)
import Data.Aeson (decode)
import Data.List ((\\))
import Data.Time.LocalTime (TimeZone, getCurrentTimeZone)
- good_statuses = case (ignore_retweets cfg) of
- True -> good_statuses' \\ retweets
- False -> good_statuses'
+ good_statuses = if (ignore_retweets cfg)
+ then good_statuses' \\ retweets
+ else good_statuses'
recurse :: Cfg -> String -> Integer -> (Maybe Message) -> IO ()
recurse cfg username latest_status_id maybe_message = do
thread_sleep (heartbeat cfg)
recurse :: Cfg -> String -> Integer -> (Maybe Message) -> IO ()
recurse cfg username latest_status_id maybe_message = do
thread_sleep (heartbeat cfg)
-- | Try continually to download username's timeline, and determine the
-- latest status id to be posted once we have done so.
-- | 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
-- If the HTTP part barfs, try again after a while.
putStrLn ("Couldn't retrieve " ++ username ++ "'s timeline. Retrying...")
thread_sleep delay
-- If the HTTP part barfs, try again after a while.
putStrLn ("Couldn't retrieve " ++ username ++ "'s timeline. Retrying...")
thread_sleep delay
-- 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
-- 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
-- This thread (the one executing main) doesn't do anything,
-- but when it terminates, so do all the threads we forked.
-- As a result, we need to keep this thread on life support.
-- This thread (the one executing main) doesn't do anything,
-- but when it terminates, so do all the threads we forked.
-- As a result, we need to keep this thread on life support.