imm-1.5.0.0: Execute arbitrary actions for each unread element of RSS/Atom feeds

Safe HaskellNone
LanguageHaskell98

Imm.Boot

Description

Getting started

Dynamic reconfiguration

This program is dynamically configured using the dyre library.

You may want to check out this documentation to know how to get started.

Your personal configuration is located at $XDG_CONFIG_HOME/imm/imm.hs.

Handle pattern

The behavior of this program can be customized through the Handle pattern.

Synopsis

Documentation

imm :: Handle IO -> Handle IO FeedTable -> Handle IO -> Handle IO -> Handle IO -> IO () Source #

Main function, meant to be used in your personal configuration file.

Here is an example:

import           Imm.Boot
import           Imm.Database.JsonFile as Database
import           Imm.Feed
import           Imm.Hooks.SendMail as Hooks
import           Imm.HTTP.Simple as HTTP
import           Imm.Logger.Simple as Logger
import           Imm.XML.Conduit as XML

main :: IO ()
main = do
  logger     <- Logger.mkHandle <$> defaultLogger
  database   <- Database.mkHandle <$> defaultDatabase
  httpClient <- HTTP.mkHandle <$> defaultManager

  imm logger database httpClient hooks xmlParser

xmlParser :: XML.Handle IO
xmlParser = XML.mkHandle defaultXmlParser

hooks :: Hooks.Handle IO
hooks = Hooks.mkHandle $ SendMailSettings smtpServer formatMail

formatMail :: FormatMail
formatMail = FormatMail
  (\a b -> (defaultFormatFrom a b) { addressEmail = "user@host" } )
  defaultFormatSubject
  defaultFormatBody
  (\_ _ -> [Address Nothing "user@host"])

smtpServer :: Feed -> FeedElement -> SMTPServer
smtpServer _ _ = SMTPServer
  (Just $ Authentication PLAIN "user" "password")
  (StartTls "smtp.host" defaultSettingsSMTPSTARTTLS)