-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.hs
71 lines (61 loc) · 2.24 KB
/
example.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wall #-}
import Prelude
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Builder as B
import qualified Data.Text.Lazy.IO as TL
import Data.Time.Clock
import System.IO
import Text.XML as XML
import Language.Google.Search.Simple as Search
import Language.Google.Search.Mail as Search
import Data.Google.Mail.Filters as Filters
main :: IO ()
main = do
now <- getCurrentTime
TL.putStrLn . XML.renderText def {rsPretty = True} $
Filters.toXML now ("Your Name", "[email protected]") filters
-- Search Terms for GMail Labs' ‘Quick Links’ by Dan P
TL.hPutStrLn stderr . TL.append "old:\t" . searchText $ orB
[ pure (Label "notification") /\ pure (Older 1 Months)
, pure (Label "dev") /\ pure (Older 6 Months)
:: Search.Mail ]
searchText :: (SearchBuilder e) => e -> TL.Text
searchText s = B.toLazyText b where PrecBuilder _prec b = searchBuilder s
filters :: [Filter]
filters =
[ Filter [Archive, LabelAs "shopping"]
$ (pure . From . orB)
, "[email protected]" ]
\/ ( pure . From $ "amazon" /\ orB
["confirm", "digital", "marketplace", "no-reply", "update"] )
\/ andB [ pure $ From "[email protected]"
, notB . pure $ Subject "reminder" ]
, Filter [Archive, LabelAs "dev"] $ orB
[ pure (From "[email protected]")
/\ pure (Cc "[email protected]")
, pure . Subject $ Exact <$> "Haskell Weekly News"
, (pure . From . orB)
, "googlecode.com"
]
]
, Filter [LabelAs "notification", MarkAsImportant False, NeverSpam]
$ (pure . From . orB)
[ "MAILER-DAEMON"
, "facebookmail.com"
, "notifications.pinterest.com"
, "plus.google.com"
]
\/ pure (List "meetup.com")
]