summaryrefslogtreecommitdiff
path: root/HsBot/Start.hs
diff options
context:
space:
mode:
Diffstat (limited to 'HsBot/Start.hs')
-rw-r--r--HsBot/Start.hs51
1 files changed, 0 insertions, 51 deletions
diff --git a/HsBot/Start.hs b/HsBot/Start.hs
deleted file mode 100644
index 97466d8..0000000
--- a/HsBot/Start.hs
+++ /dev/null
@@ -1,51 +0,0 @@
-module HsBot.Start (start) where
-
-import System
-
-import HsBot.Cmd
-import HsBot.Conf
-import HsBot.Env
-import HsBot.IRC
-import HsBot.Logics
-import HsBot.State
-import HsBot.General.Tools
-
-start :: IO ()
-start = do
- let conf = makeConf
- databaseFile <- get "databaseFile" conf
- let state = stateLoad databaseFile
- state' <- state -- Extract State from the IO Monad
- ircStart (DispatchEnv state' conf dispatch)
-
-dispatch :: Dispatch
-dispatch msg sendMessage env@(Env state conf) = dispatch' msg
- where
- dispatch' ('!':_) =
- case cmdGet msg commands of
- Just (Cmd _ _ cmdAction) -> do
- cmdAction state
- return (env)
- Nothing -> return (env)
- dispatch' _ = logicsRun msg env
- commands = [
- Cmd "!h" "Prints help" printHelp,
- Cmd "!i" "Prints infos" printInfos,
- Cmd "!p" "Prints current state" printState,
- Cmd "!s" "Stores current state to file" storeState,
- Cmd "!q" "quits" quit
- ]
- printHelp _ = printHelp' commands
- where printHelp' = sendMessage . concat . showL
- printInfos _ = do
- sendMessage $ (envGet "name" env)
- ++ " " ++ (envGet "version" env)
- ++ " (try !h)"
- printState = sendMessage . show
- storeState state = do
- sendMessage "Storing current state"
- stateSave (envGet "databaseFile" env) state
- quit state = do
- sendMessage "Good bye"
- stateSave (envGet "databaseFile" env) state
- exitWith ExitSuccess