summaryrefslogtreecommitdiff
path: root/Hsbot/Message.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-05-25 21:54:33 +0200
committerJulien Dessaux2010-05-25 22:07:58 +0200
commit451564ef5b13302912080d58a9aee6ff0968f70e (patch)
tree482d14d297d90c2696f98af39cc0cf1712d90bdd /Hsbot/Message.hs
parentImplemented update message handling in the bot's core. (diff)
downloadhsbot-451564ef5b13302912080d58a9aee6ff0968f70e.tar.gz
hsbot-451564ef5b13302912080d58a9aee6ff0968f70e.tar.bz2
hsbot-451564ef5b13302912080d58a9aee6ff0968f70e.zip
Cleaned that ugly update message handling and added a reboot command to the ircbot.
Diffstat (limited to 'Hsbot/Message.hs')
-rw-r--r--Hsbot/Message.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/Hsbot/Message.hs b/Hsbot/Message.hs
index d2cb085..c632019 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 ()
+processInternalMessage :: BotMsg -> Bot (Bool)
processInternalMessage (IntMsg msg)
| msgTo msg == "CORE" = processCoreMessage msg
| otherwise = do
@@ -17,13 +17,15 @@ processInternalMessage (IntMsg msg)
case M.lookup (msgTo msg) plugins of
Just (plugin, _) -> sendToPlugin (IntMsg msg) plugin
Nothing -> return ()
-processInternalMessage _ = return ()
+ return False
+processInternalMessage _ = return (False)
-processCoreMessage :: Msg -> Bot ()
+processCoreMessage :: Msg -> Bot (Bool)
processCoreMessage msg = do
- case msgCmd msg of
- "UPDATE" -> processUpdateCommand msg
- _ -> return ()
+ case msgType msg of
+ "UPDATE" -> processUpdateCommand msg
+ _ -> return ()
+ return $ (msgType msg) == "REBOOT"
-- | Process an update command
processUpdateCommand :: Msg -> Bot ()
@@ -31,6 +33,6 @@ processUpdateCommand msg = do
bot <- get
let oldData = botResumeData bot
from = msgFrom msg
- stuff = msgCmd msg
+ stuff = msgStuff msg
put $ bot { botResumeData = M.insert from stuff oldData }