diff options
| author | Paul Buetow <paul@buetow.org> | 2011-10-15 23:04:49 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2011-10-15 23:04:49 +0200 |
| commit | bbb1bc28fe10f1b1fdc433ecf9502e2821f024f8 (patch) | |
| tree | a89c09b339af8f69178c8eec0473cb0c86d7ca82 | |
| parent | 5875e0134d99f8e7b7b713e2a1acecedd1afe4e9 (diff) | |
initial mysql support
| -rw-r--r-- | HsBot/Base/Database.hs | 22 | ||||
| -rw-r--r-- | HsBot/Base/State.hs | 5 | ||||
| -rw-r--r-- | HsBot/Plugins/StoreMessages.hs | 7 | ||||
| -rw-r--r-- | README | 2 |
4 files changed, 27 insertions, 9 deletions
diff --git a/HsBot/Base/Database.hs b/HsBot/Base/Database.hs new file mode 100644 index 0000000..ae633e8 --- /dev/null +++ b/HsBot/Base/Database.hs @@ -0,0 +1,22 @@ +module HsBot.Base.Database where + +import HsBot.Base.Conf + +import qualified Database.HSQL.MySQL as MySQL +import qualified Database.HSQL.Types as Types + +data Database = Database { + connection :: IO Types.Connection + } + +databaseMake conf = Database { + connection = databaseMakeConnection conf + } + +databaseMakeConnection :: Conf -> IO Types.Connection +databaseMakeConnection conf = do + dbHost <- get "dbHost" conf + dbUser <- get "dbUser" conf + dbSchema <- get "dbSchema" conf + dbPass <- get "dbPass" conf + MySQL.connect dbHost dbUser dbSchema dbPass diff --git a/HsBot/Base/State.hs b/HsBot/Base/State.hs index 9c38e42..a0cc664 100644 --- a/HsBot/Base/State.hs +++ b/HsBot/Base/State.hs @@ -9,13 +9,14 @@ 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 @@ -24,7 +25,7 @@ makeDefaultState = State { currentSender = "", currentChannel = "", line = "", - users = [] + users = [], } stateNumUsers :: State -> Int diff --git a/HsBot/Plugins/StoreMessages.hs b/HsBot/Plugins/StoreMessages.hs index 47aa5dd..d5f1ace 100644 --- a/HsBot/Plugins/StoreMessages.hs +++ b/HsBot/Plugins/StoreMessages.hs @@ -1,8 +1,6 @@ module HsBot.Plugins.StoreMessages (makeStoreMessages) where import Control.Exception -import Database.HDBC --- import Database.HDBC.MySQL import HsBot.Plugins.Base @@ -11,10 +9,7 @@ import HsBot.Base.State storeMessages :: CallbackFunction storeMessages str sendMessage env@(Env state _) = do - -- connectTest - return (env) + return (env) makeStoreMessages = Plugin 0 storeMessages - -connectTest = "" @@ -1,4 +1,4 @@ REQUIREMENTS: -libghc6-haskelldb-hdbc-dev +libghc6-hsql-mysql-dev libghc6-network-dev |
