aboutsummaryrefslogtreecommitdiff
path: root/src/AdListener.hs
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-04-12 22:46:56 +0200
committerJoris Guyonvarch2015-04-12 22:47:27 +0200
commit10a9aa9391ac2995527557d9d808693b57236603 (patch)
treed1aae79b86a7d289b5733519683302c712fe96da /src/AdListener.hs
parent293fab1df23821b5f131603c4db56ab71681ce59 (diff)
downloadad-listener-10a9aa9391ac2995527557d9d808693b57236603.tar.gz
ad-listener-10a9aa9391ac2995527557d9d808693b57236603.tar.bz2
ad-listener-10a9aa9391ac2995527557d9d808693b57236603.zip
Ignore lines beginning with # in the configuration file
Diffstat (limited to 'src/AdListener.hs')
-rw-r--r--src/AdListener.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/AdListener.hs b/src/AdListener.hs
index d676b61..dbd7a71 100644
--- a/src/AdListener.hs
+++ b/src/AdListener.hs
@@ -11,7 +11,7 @@ import qualified Data.Text.IO as T
import Control.Concurrent (threadDelay)
-import Ad (getResumes, getAds)
+import Ad (fetchResumes, fetchAds)
import Model.Ad
import Model.URL
@@ -27,7 +27,7 @@ import qualified Config as C
listenToNewAds :: Config -> IO ()
listenToNewAds config = do
- eitherResumes <- getResumes (C.url config)
+ eitherResumes <- fetchResumes (C.url config)
case eitherResumes of
Left error ->
listenError config [] error
@@ -37,7 +37,7 @@ listenToNewAds config = do
listenToNewAdsWithViewedURLs :: Config -> [URL] -> IO ()
listenToNewAdsWithViewedURLs config viewedURLs = do
- eitherResumes <- getResumes (C.url config)
+ eitherResumes <- fetchResumes (C.url config)
case eitherResumes of
Left error ->
listenError config viewedURLs error
@@ -48,7 +48,7 @@ listenToNewAdsWithResumes :: Config -> [URL] -> [Resume] -> IO ()
listenToNewAdsWithResumes config viewedURLs resumes =
let (newURLs, newResumes) = getNewResumes viewedURLs resumes
in do
- eitherNewAds <- getAds newResumes
+ eitherNewAds <- fetchAds newResumes
case eitherNewAds of
Left error ->
listenError config viewedURLs error
@@ -68,7 +68,9 @@ newAdsMessage newAds =
T.concat
[ "Got "
, T.pack . show . length $ newAds
- , " new ads."
+ , " new ad"
+ , if length newAds > 1 then "s" else ""
+ , "."
]
line = T.map (\_ -> '-') newAdsMessage
in T.intercalate