From 738ad9e9bbbefb43a7889a458ff1c326a324eb9a Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 16 May 2010 17:58:38 +0200 Subject: Removed thread ids from plugins data structure. --- Hsbot/Irc/Core.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Hsbot/Irc/Core.hs') diff --git a/Hsbot/Irc/Core.hs b/Hsbot/Irc/Core.hs index ac51419..2c455ce 100644 --- a/Hsbot/Irc/Core.hs +++ b/Hsbot/Irc/Core.hs @@ -1,5 +1,5 @@ module Hsbot.Irc.Core - ( ircbot + ( startIrcbot ) where import Control.Concurrent @@ -21,8 +21,8 @@ import Hsbot.Irc.Types import Hsbot.Message (BotMsg) -- | IrcBot's main entry point -ircbot :: IrcConfig -> Chan BotMsg -> Chan BotMsg -> IO () -ircbot config masterChan myChan = do +startIrcbot :: IrcConfig -> Chan BotMsg -> Chan BotMsg -> IO () +startIrcbot config masterChan myChan = do startTime <- getCurrentTime putStrLn "[IrcBot] Opening communication channel... " chan <- newChan :: IO (Chan IrcBotMsg) @@ -55,6 +55,9 @@ ircbot config masterChan myChan = do _ <- ircBotLoop ircBotState' `catch` (\(_ :: IOException) -> return ()) return () +--resumeIrcBot +--resumeIrcBot + -- | Runs the IrcBot's reader loop ircBotReader :: Handle -> Chan IrcBotMsg -> ThreadId -> IO () ircBotReader handle chan fatherThreadId = forever $ do @@ -126,9 +129,9 @@ dispatchMessage (InIrcMsg inIrcMsg) = do let key = tail . head $ words getMsgContent pluginNames = fromMaybe [] $ M.lookup key cmds plugins' = fromMaybe [] $ mapM (flip M.lookup plugins) pluginNames - in mapM_ (sendRunCommand $ tail getMsgContent) plugins' + in mapM_ (sendRunCommand (tail getMsgContent) . fst) plugins' else - mapM_ (sendToPlugin $ InIrcMsg inIrcMsg) (M.elems plugins) + mapM_ (sendToPlugin (InIrcMsg inIrcMsg) . fst) (M.elems plugins) where isPluginCommand :: IrcConfig -> Bool isPluginCommand config = -- cgit v1.2.3