Archived
1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
hsbot/Hsbot/Message.hs
2010-05-28 22:39:45 +02:00

28 lines
783 B
Haskell

module Hsbot.Message
( processInternalMessage
) where
import Control.Monad.State
import qualified Data.Map as M
import Hsbot.PluginUtils
import Hsbot.Types
-- | Processes an internal message
processInternalMessage :: BotMsg -> Bot (BotStatus)
processInternalMessage (IntMsg msg)
| msgTo msg == "CORE" = processCoreMessage msg
| otherwise = do
plugins <- gets botPlugins
case M.lookup (msgTo msg) plugins of
Just (plugin, _) -> sendToPlugin (IntMsg msg) plugin
Nothing -> return ()
return BotContinue
processInternalMessage _ = return BotContinue
processCoreMessage :: Msg -> Bot (BotStatus)
processCoreMessage msg = do
case msgType msg of
"REBOOT" -> return BotReboot
_ -> return BotContinue