From 864a364da99a0ec05f08d7cfbad4abde416a0b06 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 24 Apr 2011 23:08:06 +0200 Subject: Some API refactoring. I can't say how I hate the Types.hs thing in Haskell! --- Hsbot/Message.hs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'Hsbot/Message.hs') diff --git a/Hsbot/Message.hs b/Hsbot/Message.hs index 5ec35ed..067a740 100644 --- a/Hsbot/Message.hs +++ b/Hsbot/Message.hs @@ -1,9 +1,21 @@ module Hsbot.Message - ( Message (..) + ( readMsg + , writeMsg ) where -import qualified Network.IRC as IRC +import Control.Concurrent +import Control.Monad.State -data Message = IncomingMsg IRC.Message - | OutgoingMsg IRC.Message +import Hsbot.Types + +-- Plugin Utils +readMsg :: Plugin IO (Message) +readMsg = do + chan <- gets pluginChan + liftIO $ readChan chan >>= return + +writeMsg :: Message -> Plugin IO () +writeMsg msg = do + chan <- gets pluginMaster + liftIO $ writeChan chan msg -- cgit v1.2.3