Browse Source

Fixes broken build because of change in bot config.

Abhinav Sarkar 5 years ago
parent
commit
231fad8ca2
2 changed files with 14 additions and 4 deletions
  1. 5
    3
      hask-irc-runner/Network/IRC/Config.hs
  2. 9
    1
      hask-irc-runner/config.cfg.template

+ 5
- 3
hask-irc-runner/Network/IRC/Config.hs View File

@@ -8,6 +8,7 @@ import qualified Data.Ratio as R
8 8
 
9 9
 import ClassyPrelude
10 10
 import Data.Configurator.Types (Configured (..), ConfigError (..), KeyError (..))
11
+import Prelude                 (read)
11 12
 
12 13
 import Network.IRC
13 14
 import Network.IRC.Configuration
@@ -39,8 +40,8 @@ loadBotConfig :: String -> IO BotConfig
39 40
 loadBotConfig configFile = do
40 41
   eConfig <- try $ CF.load [CF.Required configFile]
41 42
   case eConfig of
42
-    Left (ParseError _ _) -> error "Error while loading config"
43
-    Right config          -> do
43
+    Left (ParseError _ msg) -> error $ "Error while loading config: " ++ msg
44
+    Right config            -> do
44 45
       eBotConfig <- try $ do
45 46
         handlers :: [Text] <- CF.require config "msghandlers"
46 47
         let handlerInfo    = foldl' (\m h -> insertMap h mempty m) mempty handlers
@@ -53,7 +54,8 @@ loadBotConfig configFile = do
53 54
                        CF.require config "port"            <*>
54 55
                        CF.require config "channel"         <*>
55 56
                        (Nick <$> CF.require config "nick") <*>
56
-                       CF.require config "timeout"
57
+                       CF.require config "timeout"         <*>
58
+                       (read <$> CF.require config "loglevel")
57 59
         configMap <- fromConfiguratorConfig config
58 60
         return botConfig { msgHandlerInfo   = handlerInfo
59 61
                          , msgHandlerMakers = handlerMakers

config.cfg.template → hask-irc-runner/config.cfg.template View File

@@ -4,7 +4,15 @@ channel = "#testtesttest"
4 4
 nick = "haskman"
5 5
 password = "xxxsss"
6 6
 timeout = 130
7
-msghandlers = ["greeter", "welcomer", "messagelogger", "songsearch", "auth", "nicktracker", "tell"]
7
+loglevel = "INFO"
8
+
9
+msghandlers = [ "greeter"
10
+              , "welcomer"
11
+              , "messagelogger"
12
+              , "songsearch"
13
+              , "auth"
14
+              , "nicktracker"
15
+              , "tell"]
8 16
 
9 17
 songsearch {
10 18
   tinysong_apikey = "xxxyyyzzz"

Loading…
Cancel
Save