diff options
Diffstat (limited to 'HsBot')
| -rw-r--r-- | HsBot/Base/Database.hs | 22 | ||||
| -rw-r--r-- | HsBot/Base/State.hs | 5 | ||||
| -rw-r--r-- | HsBot/Plugins/StoreMessages.hs | 7 |
3 files changed, 26 insertions, 8 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 = "" |
