summaryrefslogtreecommitdiff
path: root/HsBot
diff options
context:
space:
mode:
authorpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2010-03-28 11:52:17 +0000
committerpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2010-03-28 11:52:17 +0000
commited66eb310a9ec78901e6a3be2275f9de62ad5708 (patch)
treef37e37f47e0ea693200d1a0783796cb45e6bdb2c /HsBot
parent3d7e9915c4fab6f91f11b3de66ac8bbcb8b3c0c7 (diff)
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@52 9f8f72e9-4bf4-416e-b76e-7d4203597157
Diffstat (limited to 'HsBot')
-rw-r--r--HsBot/Base/Env.hs3
-rw-r--r--HsBot/Base/State.hs1
-rw-r--r--HsBot/IRC.hs6
-rw-r--r--HsBot/Logics/Dummy.hs9
4 files changed, 13 insertions, 6 deletions
diff --git a/HsBot/Base/Env.hs b/HsBot/Base/Env.hs
index 36fafd5..e5a9133 100644
--- a/HsBot/Base/Env.hs
+++ b/HsBot/Base/Env.hs
@@ -18,3 +18,6 @@ envGet :: String -> Env -> String
envGet key (Env _ conf) = getUnwrapped key conf
envGet key env = envGet key (castEnv env)
+envState :: Env -> State
+envState (Env state _) = state
+envState env = envState (castEnv env)
diff --git a/HsBot/Base/State.hs b/HsBot/Base/State.hs
index abcf479..6d4efdc 100644
--- a/HsBot/Base/State.hs
+++ b/HsBot/Base/State.hs
@@ -6,6 +6,7 @@ import List
import HsBot.IRC.User
data State = State {
+ isReady :: Bool,
currentChannel :: String,
line :: String,
users :: [User]
diff --git a/HsBot/IRC.hs b/HsBot/IRC.hs
index cf1a1e8..da488ea 100644
--- a/HsBot/IRC.hs
+++ b/HsBot/IRC.hs
@@ -60,7 +60,7 @@ ircStart (DispatchEnv state conf dispatch) = do
hSetBuffering h NoBuffering
ircWrite h "NICK" ircNick
ircWrite h "USER" $ ircNick ++ " 0 * :" ++ ircUser
- ircEvalLoop h (DispatchEnv state { currentChannel = ircChannel } conf dispatch)
+ ircEvalLoop h (DispatchEnv state { isReady = False, currentChannel = ircChannel } conf dispatch)
return ()
ircEvalLoop :: Handle -> Env -> IO ()
@@ -84,11 +84,11 @@ ircEvalLoop h env = do
}
ircEval :: Handle -> IrcMessage -> Env -> IO Env
-ircEval h msg env@(DispatchEnv state _ dispatch) = ircEval' (clean msg)
+ircEval h msg env@(DispatchEnv state conf dispatch) = ircEval' (clean msg)
where
ircEval' "+x" = do
ircWrite h "JOIN" (currentChannel state)
- return (env)
+ return (DispatchEnv state { isReady = True } conf dispatch)
ircEval' cleanMsg = do
(Env s c) <- dispatch cleanMsg sendReplyMsg (castEnv env)
return (DispatchEnv s c dispatch)
diff --git a/HsBot/Logics/Dummy.hs b/HsBot/Logics/Dummy.hs
index a873f8a..be32a50 100644
--- a/HsBot/Logics/Dummy.hs
+++ b/HsBot/Logics/Dummy.hs
@@ -1,10 +1,13 @@
module HsBot.Logics.Dummy (dummyRun) where
import HsBot.Base.Env
+import HsBot.Base.State
dummyRun :: String -> SendMessage -> Env -> IO Env
-dummyRun str sendMessage env = do
- --sendMessage "Hello World"
- putStrLn str
+dummyRun str sendMessage env@(Env state _) = do
+ if isReady state
+ --then sendMessage "Hello World"
+ then putStrLn $ "::::" ++ str
+ else putStrLn str
return (env)