| 1 |
{-# LANGUAGE DeriveDataTypeable #-} |
| 2 |
{-# LANGUAGE GADTs #-} |
| 3 |
{-# LANGUAGE TemplateHaskell #-} |
| 4 |
{-# LANGUAGE TypeOperators #-} |
| 5 |
{-# OPTIONS_GHC -fno-warn-overlapping-patterns #-} |
| 6 |
module Lambdabot.Config.Core |
| 7 |
( commandPrefixes |
| 8 |
, disabledCommands |
| 9 |
, editDistanceLimit |
| 10 |
, enableInsults |
| 11 |
, onStartupCmds |
| 12 |
, outputDir |
| 13 |
, dataDir |
| 14 |
, lbVersion |
| 15 |
, textWidth |
| 16 |
, uncaughtExceptionHandler |
| 17 |
|
| 18 |
, replaceRootLogger |
| 19 |
, lbRootLoggerPath |
| 20 |
, consoleLogHandle |
| 21 |
, consoleLogLevel |
| 22 |
, consoleLogFormat |
| 23 |
) where |
| 24 |
|
| 25 |
import Lambdabot.Config |
| 26 |
import Lambdabot.Logging |
| 27 |
|
| 28 |
import Control.Exception |
| 29 |
import System.IO |
| 30 |
import Data.Version |
| 31 |
|
| 32 |
------------------------------------- |
| 33 |
-- Core configuration variables |
| 34 |
|
| 35 |
config "commandPrefixes" [t| [String] |] [| ["@", "?"] |] |
| 36 |
config "disabledCommands" [t| [String] |] [| [] |] |
| 37 |
config "editDistanceLimit" [t| Int |] [| 3 :: Int |] |
| 38 |
config "enableInsults" [t| Bool |] [| True |] |
| 39 |
configWithMerge [| (++) |] "onStartupCmds" [t| [String] |] [| ["offline"] |] |
| 40 |
config "outputDir" [t| FilePath |] [| "State/" |] |
| 41 |
-- the dataDir variable will be filled by lambdabot's executable |
| 42 |
config "dataDir" [t| FilePath |] [| "." |] |
| 43 |
-- ditto for lbVersion |
| 44 |
config "lbVersion" [t| Version |] [| Version [] [] |] |
| 45 |
|
| 46 |
-- IRC maximum msg length, minus a bit for safety. |
| 47 |
config "textWidth" [t| Int |] [| 200 :: Int |] |
| 48 |
|
| 49 |
-- basic logging. for more complex setups, configure directly using System.Log.Logger |
| 50 |
config "replaceRootLogger" [t| Bool |] [| True |] |
| 51 |
config "lbRootLoggerPath" [t| [String] |] [| [] |] |
| 52 |
config "consoleLogHandle" [t| Handle |] [| stderr |] |
| 53 |
config "consoleLogLevel" [t| Priority |] [| NOTICE |] |
| 54 |
config "consoleLogFormat" [t| String |] [| "[$prio] $loggername: $msg" |] |
| 55 |
|
| 56 |
-------------------------------------------- |
| 57 |
-- Default values with longer definitions |
| 58 |
|
| 59 |
defaultIrcHandler :: SomeException -> IO () |
| 60 |
defaultIrcHandler = errorM . ("Main: caught (and ignoring) "++) . show |
| 61 |
|
| 62 |
type DIH = SomeException -> IO () |
| 63 |
-- work around a TemplateHaskell bug in ghc-8.6.1 |
| 64 |
-- see https://ghc.haskell.org/trac/ghc/ticket/15815 |
| 65 |
|
| 66 |
config "uncaughtExceptionHandler" [t| DIH |] [| defaultIrcHandler |] |