summaryrefslogtreecommitdiff
path: root/Hsbot/Core.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-02-04 23:34:15 +0100
committerJulien Dessaux2010-02-04 23:34:15 +0100
commit416460886da9f8d835200ca46c9062a4ebd78fe7 (patch)
treef76663fd592d13031f494674c8c602e624f1d03d /Hsbot/Core.hs
parentBegan a complete rewrite of command and plugin management. (diff)
downloadhsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.tar.gz
hsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.tar.bz2
hsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.zip
Continue rewriting, found a problem in the way I kill plugins.
Diffstat (limited to 'Hsbot/Core.hs')
-rw-r--r--Hsbot/Core.hs12
1 files changed, 7 insertions, 5 deletions
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