diff options
| author | Paul Buetow <paul@buetow.org> | 2011-10-15 23:52:02 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2011-10-15 23:52:02 +0200 |
| commit | 74bbc61e4dd44569d7f6b5eaa1b97cd00685cfc9 (patch) | |
| tree | a66d8a0062543507e4e27f74a6e8d94034caee26 | |
| parent | bbb1bc28fe10f1b1fdc433ecf9502e2821f024f8 (diff) | |
some testing stuff
| -rw-r--r-- | HsBot/Base/Conf.hs | 2 | ||||
| -rw-r--r-- | HsBot/Base/Database.hs | 20 | ||||
| -rw-r--r-- | HsBot/Base/State.hs | 7 | ||||
| -rw-r--r-- | Makefile | 2 |
4 files changed, 19 insertions, 12 deletions
diff --git a/HsBot/Base/Conf.hs b/HsBot/Base/Conf.hs index 774f473..9c55180 100644 --- a/HsBot/Base/Conf.hs +++ b/HsBot/Base/Conf.hs @@ -14,7 +14,7 @@ makeConf = M.fromList , ("ircChannel", "#buetow.org") , ("ircNick", "hotdog") , ("ircPort", "6667") - , ("ircUser", "hsbot.haskell.eu") + , ("ircUser", "hsbot.buetow.org") , ("dbHost", "localhost") , ("dbUser", "hsbot") , ("dbPass", "hsbot") diff --git a/HsBot/Base/Database.hs b/HsBot/Base/Database.hs index ae633e8..46a16d4 100644 --- a/HsBot/Base/Database.hs +++ b/HsBot/Base/Database.hs @@ -6,17 +6,21 @@ import qualified Database.HSQL.MySQL as MySQL import qualified Database.HSQL.Types as Types data Database = Database { - connection :: IO Types.Connection - } + connection :: IO Types.Connection, + connectionString :: String + } -databaseMake conf = Database { - connection = databaseMakeConnection conf - } +instance Show Database where + show database = show $ connectionString database -databaseMakeConnection :: Conf -> IO Types.Connection -databaseMakeConnection conf = do +databaseMake :: Conf -> IO Database +databaseMake conf = do dbHost <- get "dbHost" conf dbUser <- get "dbUser" conf dbSchema <- get "dbSchema" conf dbPass <- get "dbPass" conf - MySQL.connect dbHost dbUser dbSchema dbPass + return $ Database { + connection = MySQL.connect dbHost dbUser dbSchema dbPass, + connectionString = dbHost ++ " " ++ dbUser ++ " " ++ dbSchema ++ " " ++ dbPass + } + diff --git a/HsBot/Base/State.hs b/HsBot/Base/State.hs index a0cc664..f501a16 100644 --- a/HsBot/Base/State.hs +++ b/HsBot/Base/State.hs @@ -5,18 +5,19 @@ module HsBot.Base.State where +import HsBot.Base.Database + import qualified Data.Map as M import List import HsBot.IRC.User -import HsBot.Base.Database data State = State { isReady :: Bool, currentSender :: String, currentChannel :: String, line :: String, - users :: [User], + users :: [User] } deriving (Show, Read) makeDefaultState :: State @@ -25,7 +26,7 @@ makeDefaultState = State { currentSender = "", currentChannel = "", line = "", - users = [], + users = [] } stateNumUsers :: State -> Int @@ -1,5 +1,7 @@ all: ghc --make Main.hs -o hsbot +ghci: + ghci Main.hs clean: find . -name \*.o | xargs rm find . -name \*.hi | xargs rm |
