diff options
author | Julien Dessaux | 2010-05-29 22:38:18 +0200 |
---|---|---|
committer | Julien Dessaux | 2010-05-29 23:55:12 +0200 |
commit | 9dda7dc1b9aa3118a4b320185264b5e6079d041a (patch) | |
tree | 17b208583acf0ce670b6326e0b2eda992f03cfb4 /Hsbot/Message.hs | |
parent | Rationalized the way bot configs are handled. (diff) | |
download | hsbot-9dda7dc1b9aa3118a4b320185264b5e6079d041a.tar.gz hsbot-9dda7dc1b9aa3118a4b320185264b5e6079d041a.tar.bz2 hsbot-9dda7dc1b9aa3118a4b320185264b5e6079d041a.zip |
Added signal handling and a better semantic for bot status.
Diffstat (limited to 'Hsbot/Message.hs')
-rw-r--r-- | Hsbot/Message.hs | 15 |
1 files changed, 11 insertions, 4 deletions
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 + |