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
33
34
35
36
|
module HsBot.Base.Conf where
import qualified Data.Map as M
type Conf = M.Map String String
makeConf = M.fromList
[ ("name", "HsBot")
, ("version", "v0.0")
, ("databaseFile", "hsbot.db")
, ("maxMessageSize", "400")
, ("admin", "rantanplan")
, ("ircServer", "irc.german-elite.net")
, ("ircChannel", "#buetow.org")
, ("ircNick", "hotdog")
, ("ircPort", "6667")
, ("ircUser", "hsbot.haskell.eu")
, ("dbHost", "localhost")
, ("dbUser", "hsbot")
, ("dbPass", "hsbot")
, ("dbSchema", "hsbot")
]
get :: (Monad m) => String -> Conf -> m String
get key conf = case M.lookup key conf of
Just val -> return (val)
Nothing -> return ("")
getUnwrappedInt :: String -> Conf -> Int
getUnwrappedInt key conf = read (getUnwrapped key conf) :: Int
getUnwrapped :: String -> Conf -> String
getUnwrapped key conf =
case M.lookup key conf of
Just val -> val
Nothing -> ""
|