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/Types.hs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'Hsbot/Types.hs') diff --git a/Hsbot/Types.hs b/Hsbot/Types.hs index 9ea7ff6..49e8e6b 100644 --- a/Hsbot/Types.hs +++ b/Hsbot/Types.hs @@ -1,10 +1,14 @@ module Hsbot.Types ( Bot , BotMsg (..) + , BotResumeData , BotState (..) + , BotStatus (..) , Msg (..) , Plugin , PluginState (..) + , ResumeData + , ResumeMsg (..) ) where import Control.Concurrent @@ -24,10 +28,16 @@ data BotState = BotState , botPlugins :: M.Map String (PluginState, ThreadId) -- Loaded plugins , botChan :: Chan BotMsg -- the bot's communication channel , botConfig :: Config -- the bot's starting config - , botMVar :: MVar String -- the place where to put resume data - , botResumeData :: M.Map String String -- the necessary data to resume the bot's operations on reboot + , botResumeData :: MVar BotResumeData -- the necessary data to resume the bot's operations on reboot } +-- | how we exit from the botLoop +data BotStatus = BotExit | BotReboot | BotContinue deriving (Eq) + +-- | Types to factorise resume data +type ResumeData = M.Map String String +type BotResumeData = M.Map String ResumeData + -- | The Plugin monad type Plugin = StateT PluginState IO @@ -46,5 +56,10 @@ data Msg = Msg , msgStuff :: String -- the message to be transfered } deriving (Show) -data BotMsg = InMsg Msg | OutMsg Msg | IntMsg Msg deriving (Show) +data ResumeMsg = ResMsg + { resMsgFrom :: String + , resMsgData :: ResumeData + } deriving (Show) + +data BotMsg = InMsg Msg | OutMsg Msg | IntMsg Msg | UpdMsg ResumeMsg deriving (Show) -- cgit v1.2.3