From 416460886da9f8d835200ca46c9062a4ebd78fe7 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 4 Feb 2010 23:34:15 +0100 Subject: Continue rewriting, found a problem in the way I kill plugins. --- Hsbot/Core.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Hsbot/Core.hs') diff --git a/Hsbot/Core.hs b/Hsbot/Core.hs index 2de1507..a8f29ec 100644 --- a/Hsbot/Core.hs +++ b/Hsbot/Core.hs @@ -13,6 +13,7 @@ import System.IO import System.Time (getClockTime) import Hsbot.IRCParser +import Hsbot.Plugin import Hsbot.Types import Hsbot.Utils @@ -32,11 +33,12 @@ connectServer server = do return $ Bot server starttime handle [] M.empty chan threadId M.empty -- | Disconnect from the server -disconnectServer :: Bot -> IO () -- IO Bot ? -disconnectServer bot = do - killThread $ readerThreadId bot - mapM_ (killThread . pluginThreadId . snd) (M.toList $ botPlugins bot) - hClose $ botHandle bot +disconnectServer :: IrcBot () +disconnectServer = do + bot <- get + liftIO $ killThread $ readerThreadId bot + mapM_ unloadPlugin (M.keys $ botPlugins bot) + liftIO $ hClose $ botHandle bot return () -- | Socket reading loop -- cgit v1.2.3