aboutsummaryrefslogtreecommitdiff
path: root/src/Tomato/App.hs
blob: 14bf61af8c0c985d34448cd84774cff35068159f (plain)
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
module Tomato.App
  ( App (..)
  , runApp
  ) where

import RIO


data App = App
    { appLogFunc  :: !LogFunc
    , appToken    :: !ByteString
    , appBotId    :: !Text
    , appFile     :: !FilePath
    , appClientId :: !Text
    }

instance HasLogFunc App where
    logFuncL = lens appLogFunc (\x y -> x { appLogFunc = y })

runApp :: RIO App a -> IO a
runApp inner = do
  logOptions' <- logOptionsHandle stderr False
  let logOptions = setLogUseTime True $ setLogUseLoc True logOptions'
  withLogFunc logOptions $ \logFunc -> do
    let app = App
          { appLogFunc = logFunc
          , appToken = "t2YhlxxwZmn2cWfkAomjMc6BgVPMaC5NRkqHzGQl"
          , appBotId = "713bcb4a4604006c944804552c"
          , appFile = "tomato.png"
          , appClientId = "FbzqI-oR7277JwL1ZGsyUw7yG1F5U0U3WhQ3kOW71Do"
          }
    runRIO app inner