Added signal handling and a better semantic for bot status.
This commit is contained in:
parent
57bec4921b
commit
9dda7dc1b9
4 changed files with 39 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
Reference in a new issue