diff options
| author | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-28 12:34:12 +0000 |
|---|---|---|
| committer | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-28 12:34:12 +0000 |
| commit | 4f80cd186f21d9bb6fb3c0ae31e7626c21f531c6 (patch) | |
| tree | 1179fc5a7a619b48aecf059cb5460f40ef5782db /HsBot | |
| parent | ed66eb310a9ec78901e6a3be2275f9de62ad5708 (diff) | |
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@53 9f8f72e9-4bf4-416e-b76e-7d4203597157
Diffstat (limited to 'HsBot')
| -rw-r--r-- | HsBot/Logics.hs | 21 | ||||
| -rw-r--r-- | HsBot/Logics/Dummy.hs | 7 |
2 files changed, 14 insertions, 14 deletions
diff --git a/HsBot/Logics.hs b/HsBot/Logics.hs index 9b98300..e66a238 100644 --- a/HsBot/Logics.hs +++ b/HsBot/Logics.hs @@ -1,15 +1,18 @@ -module HsBot.Logics (logicsRun) where +module HsBot.Callbacks (logicsRun) where import HsBot.Base.Env -import HsBot.Logics.Dummy +import HsBot.Base.State +import HsBot.Callbacks.Dummy -registeredLogics = [dummyRun] +registeredCallbacks = [dummyRun] logicsRun :: String -> SendMessage -> Env -> IO Env -logicsRun = logicsRun' registeredLogics - where - logicsRun' [] sendMessage str env = return (env) - logicsRun' (logic:ls) sendMessage str env = do - env' <- logic sendMessage str env - logicsRun' ls sendMessage str env' +logicsRun str sendMessage env@(Env state _) + | isReady state = logicsRun' registeredCallbacks env + | otherwise = do { putStrLn str; return (env) } + where + logicsRun' [] env = return (env) + logicsRun' (logic:rest) env = do + env' <- logic str sendMessage env + logicsRun' rest env' diff --git a/HsBot/Logics/Dummy.hs b/HsBot/Logics/Dummy.hs index be32a50..edc8056 100644 --- a/HsBot/Logics/Dummy.hs +++ b/HsBot/Logics/Dummy.hs @@ -1,13 +1,10 @@ -module HsBot.Logics.Dummy (dummyRun) where +module HsBot.Callbacks.Dummy (dummyRun) where import HsBot.Base.Env import HsBot.Base.State dummyRun :: String -> SendMessage -> Env -> IO Env dummyRun str sendMessage env@(Env state _) = do - if isReady state - --then sendMessage "Hello World" - then putStrLn $ "::::" ++ str - else putStrLn str + putStrLn $ "::::" ++ str return (env) |
