From 9dda7dc1b9aa3118a4b320185264b5e6079d041a Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 29 May 2010 22:38:18 +0200 Subject: Added signal handling and a better semantic for bot status. --- Hsbot/Message.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Hsbot/Message.hs') diff --git a/Hsbot/Message.hs b/Hsbot/Message.hs index f38438f..933394b 100644 --- a/Hsbot/Message.hs +++ b/Hsbot/Message.hs @@ -1,5 +1,7 @@ module Hsbot.Message ( processInternalMessage + , processRebootMessage + , processExitMessage ) where import Control.Monad.State @@ -9,16 +11,15 @@ import Hsbot.PluginUtils import Hsbot.Types -- | Processes an internal message -processInternalMessage :: BotMsg -> Bot (BotStatus) -processInternalMessage (IntMsg msg) +processInternalMessage :: Msg -> Bot (BotStatus) +processInternalMessage msg | msgTo msg == "CORE" = processCoreMessage msg | otherwise = do plugins <- gets botPlugins case M.lookup (msgTo msg) plugins of - Just (plugin, _) -> sendToPlugin (IntMsg msg) plugin + Just (plugin, _, _) -> sendToPlugin (IntMsg msg) plugin Nothing -> return () return BotContinue -processInternalMessage _ = return BotContinue processCoreMessage :: Msg -> Bot (BotStatus) processCoreMessage msg = do @@ -26,3 +27,9 @@ processCoreMessage msg = do "REBOOT" -> return BotReboot _ -> return BotContinue +processRebootMessage :: RebootMsg -> Bot (BotStatus) +processRebootMessage _ = return BotReboot -- TODO : check who is sending that to us + +processExitMessage :: ExitMsg -> Bot (BotStatus) +processExitMessage _ = return BotExit -- TODO : check who is sending that to us + -- cgit v1.2.3