]> gitweb.michael.orlitzky.com - dead/halcyon.git/blobdiff - src/Main.hs
Add the Twitter API oAuth stuff to the configuration and command line.
[dead/halcyon.git] / src / Main.hs
index bf99fe853fd2e947a5e1508cb8eeb9ddf92d835f..8c81555c60075952980b48198d3ee1f38ab5ec7e 100644 (file)
@@ -104,7 +104,7 @@ filter_statuses cfg ss =
 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
@@ -137,9 +137,10 @@ recurse cfg username latest_status_id maybe_message = do
 
 -- | 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
@@ -147,7 +148,7 @@ get_latest_status_id delay username = do
       -- 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)
 
 
@@ -159,7 +160,7 @@ get_latest_status_id delay username = do
 --   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 ()
 
@@ -205,7 +206,7 @@ main = do
 
   -- 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