diff options
| author | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-16 20:54:13 +0000 |
|---|---|---|
| committer | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-16 20:54:13 +0000 |
| commit | e439488acb7e8a71703f8cb3d4e70340652359d3 (patch) | |
| tree | 9921fb8a419f47b269f6ef1c1a56a157c939639a | |
| parent | d3dc3957e68ea83e348897b3b9d6fe3e280b5d11 (diff) | |
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@33 9f8f72e9-4bf4-416e-b76e-7d4203597157
| -rw-r--r-- | Env.hs | 2 | ||||
| -rw-r--r-- | IRC.hs | 9 | ||||
| -rw-r--r-- | Main.hs | 2 |
3 files changed, 7 insertions, 6 deletions
@@ -4,7 +4,7 @@ import Conf import State type Dispatch = String -> (String -> IO ()) -> Env -> IO () -data Env = Env State Conf Dispatch +data Env = Env State Conf Dispatch | EnvWoDispatch State Conf envGetInt :: String -> Env -> Int envGetInt key (Env _ conf _) = getUnwrappedInt key conf @@ -26,7 +26,7 @@ ircWrite h s t = do hPrintf h "%s %s\r\n" s t ircPrivMsg :: Handle -> IrcMessage -> Env -> String -> IO () -ircPrivMsg h msg (Env state conf _) s = do +ircPrivMsg h msg (EnvWoDispatch state conf) s = do if isMultiline s then ircPrivMsg' (lines s) else ircPrivMsg' [s] @@ -85,13 +85,14 @@ ircEvalLoop h env = forever $ do pong x = ircWrite h "PONG" (':' : drop 6 x) ircEval :: Handle -> IrcMessage -> Env -> IO () -ircEval h msg env@(Env state _ dispatch) = +ircEval h msg env@(Env state conf dispatch) = case isCommand (clean msg) of - Just cmd -> dispatch cmd sendReplyMsg env + Just cmd -> dispatch cmd sendReplyMsg envWoDispatch Nothing -> evalServerMessage (clean msg) where + envWoDispatch = (EnvWoDispatch state conf) isCommand ('!':xs) = Just xs isCommand _ = Nothing evalServerMessage "+x" = ircWrite h "JOIN" (currentChannel state) evalServerMessage _ = putStrLn $ show msg - sendReplyMsg = ircPrivMsg h msg env + sendReplyMsg = ircPrivMsg h msg envWoDispatch @@ -22,7 +22,7 @@ r :: IO () r = main dispatch :: Dispatch -dispatch cmd sendMessage env@(Env state conf _) = +dispatch cmd sendMessage env@(EnvWoDispatch state conf) = let commands = [ Cmd "!h" "Prints help" printHelp, Cmd "!i" "Prints infos" printInfos, |
