From d4be110200ba3f3a2f19236ec3c16f980ab458aa Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 23 Apr 2011 13:35:04 +0200 Subject: Continue refactoring, worked on the core loop and the plugin infrastructure. --- Hsbot/Types.hs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'Hsbot/Types.hs') diff --git a/Hsbot/Types.hs b/Hsbot/Types.hs index ff57c49..28ad430 100644 --- a/Hsbot/Types.hs +++ b/Hsbot/Types.hs @@ -5,6 +5,8 @@ module Hsbot.Types , BotEnv (..) , Env , Message (..) + , Plugin + , PluginId (..) , PluginState (..) ) where @@ -12,11 +14,11 @@ import Control.Concurrent import qualified Data.Map as M import Control.Monad.Reader import Control.Monad.State -import qualified Network.IRC as IRC import Network.TLS import System.IO import Hsbot.Config +import Hsbot.Message -- The bot environment type Env = ReaderT BotEnv @@ -36,19 +38,24 @@ type Bot = StateT BotState data BotState = BotState { botPlugins :: M.Map String (PluginState, MVar (), ThreadId) - , botCommands :: M.Map String [String] + , botHooks :: [Chan Message] , botChannels :: [String] , botNickname :: String } -- The Plugin monad +type Plugin = StateT PluginState + data PluginState = PluginState + { pluginId :: PluginId + , pluginChan :: Chan Message + , pluginMaster :: Chan Message + } + +data PluginId = PluginId { pluginName :: String - , pluginChan :: Chan Message + , pluginEp :: PluginState -> IO () } data BotStatus = BotContinue | BotExit | BotReload | BotRestart deriving (Show) -data Message = IncomingMsg IRC.Message - | OutgoingMsg IRC.Message - -- cgit v1.2.3