aboutsummaryrefslogtreecommitdiff
path: root/src/AdListener.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/AdListener.hs')
-rw-r--r--src/AdListener.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/AdListener.hs b/src/AdListener.hs
index dbd7a71..0155074 100644
--- a/src/AdListener.hs
+++ b/src/AdListener.hs
@@ -25,6 +25,8 @@ import Parser.Detail
import Config (Config)
import qualified Config as C
+import Time (getCurrentFormattedTime)
+
listenToNewAds :: Config -> IO ()
listenToNewAds config = do
eitherResumes <- fetchResumes (C.url config)
@@ -54,23 +56,25 @@ listenToNewAdsWithResumes config viewedURLs resumes =
listenError config viewedURLs error
Right newAds ->
do
+ time <- getCurrentFormattedTime
if not (null newAds)
then
- T.putStrLn (newAdsMessage newAds)
+ T.putStrLn (newAdsMessage time newAds)
else
return ()
waitOneMinute
listenToNewAdsWithViewedURLs config (viewedURLs ++ newURLs)
-newAdsMessage :: [Ad] -> Text
-newAdsMessage newAds =
+newAdsMessage :: Text -> [Ad] -> Text
+newAdsMessage time newAds =
let newAdsMessage =
T.concat
- [ "Got "
+ [ "\nAt "
+ , time
+ , ", got "
, T.pack . show . length $ newAds
, " new ad"
, if length newAds > 1 then "s" else ""
- , "."
]
line = T.map (\_ -> '-') newAdsMessage
in T.intercalate