summaryrefslogtreecommitdiff
path: root/Hsbot/Message.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-05-28 22:39:45 +0200
committerJulien Dessaux2010-05-28 22:39:45 +0200
commitc506c58e925383a6a19c82550d1bb458bc504f99 (patch)
tree5ff9e1beefd8058b4e791b135f2aaaf641fe2d4b /Hsbot/Message.hs
parentCleaned that ugly update message handling and added a reboot command to the i... (diff)
downloadhsbot-c506c58e925383a6a19c82550d1bb458bc504f99.tar.gz
hsbot-c506c58e925383a6a19c82550d1bb458bc504f99.tar.bz2
hsbot-c506c58e925383a6a19c82550d1bb458bc504f99.zip
Cleaned further the bot updates handling.
Diffstat (limited to '')
-rw-r--r--Hsbot/Message.hs22
1 files changed, 6 insertions, 16 deletions
diff --git a/Hsbot/Message.hs b/Hsbot/Message.hs
index c632019..f38438f 100644
--- a/Hsbot/Message.hs
+++ b/Hsbot/Message.hs
@@ -9,7 +9,7 @@ import Hsbot.PluginUtils
import Hsbot.Types
-- | Processes an internal message
-processInternalMessage :: BotMsg -> Bot (Bool)
+processInternalMessage :: BotMsg -> Bot (BotStatus)
processInternalMessage (IntMsg msg)
| msgTo msg == "CORE" = processCoreMessage msg
| otherwise = do
@@ -17,22 +17,12 @@ processInternalMessage (IntMsg msg)
case M.lookup (msgTo msg) plugins of
Just (plugin, _) -> sendToPlugin (IntMsg msg) plugin
Nothing -> return ()
- return False
-processInternalMessage _ = return (False)
+ return BotContinue
+processInternalMessage _ = return BotContinue
-processCoreMessage :: Msg -> Bot (Bool)
+processCoreMessage :: Msg -> Bot (BotStatus)
processCoreMessage msg = do
case msgType msg of
- "UPDATE" -> processUpdateCommand msg
- _ -> return ()
- return $ (msgType msg) == "REBOOT"
-
--- | Process an update command
-processUpdateCommand :: Msg -> Bot ()
-processUpdateCommand msg = do
- bot <- get
- let oldData = botResumeData bot
- from = msgFrom msg
- stuff = msgStuff msg
- put $ bot { botResumeData = M.insert from stuff oldData }
+ "REBOOT" -> return BotReboot
+ _ -> return BotContinue