From c506c58e925383a6a19c82550d1bb458bc504f99 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 28 May 2010 22:39:45 +0200 Subject: Cleaned further the bot updates handling. --- Hsbot/Message.hs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'Hsbot/Message.hs') 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 -- cgit v1.2.3