Fixes broken build because of change in bot config.

master
Abhinav Sarkar 2015-06-30 00:52:07 +05:30
parent 9d43374cdb
commit 231fad8ca2
2 changed files with 14 additions and 4 deletions

View File

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

View File

@ -4,7 +4,15 @@ channel = "#testtesttest"
nick = "haskman" nick = "haskman"
password = "xxxsss" password = "xxxsss"
timeout = 130 timeout = 130
msghandlers = ["greeter", "welcomer", "messagelogger", "songsearch", "auth", "nicktracker", "tell"] loglevel = "INFO"
msghandlers = [ "greeter"
, "welcomer"
, "messagelogger"
, "songsearch"
, "auth"
, "nicktracker"
, "tell"]
songsearch { songsearch {
tinysong_apikey = "xxxyyyzzz" tinysong_apikey = "xxxyyyzzz"