From 7dfc802b753f21afcb656b13d30d49bc548ac150 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 17 Apr 2020 22:41:53 +0200 Subject: Reaktor.API: make configurable --- src/main.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/main.hs') diff --git a/src/main.hs b/src/main.hs index 89966c2..51bc17c 100644 --- a/src/main.hs +++ b/src/main.hs @@ -23,7 +23,7 @@ main = do v <- preview _Value <$> readFile configPath - Reaktor.run (reaktorConfig v) $ \actions -> + Reaktor.run (reaktorConfig v) (apiConfig v) $ \actions -> mapM id [ Reaktor.Plugins.Mention.new actions, Reaktor.Plugins.Ping.new actions, @@ -32,6 +32,11 @@ main = do ] +apiConfig :: (FromJSON b) => Maybe Value -> Maybe b +apiConfig = \case + Just v -> maybe Nothing parseOrDie (v ^? key "API") + Nothing -> Nothing + reaktorConfig :: (FromJSON b, Default b) => Maybe Value -> b reaktorConfig = maybe def parseOrDie -- cgit v1.2.3