diff options
author | Julien Dessaux | 2010-02-04 23:34:15 +0100 |
---|---|---|
committer | Julien Dessaux | 2010-02-04 23:34:15 +0100 |
commit | 416460886da9f8d835200ca46c9062a4ebd78fe7 (patch) | |
tree | f76663fd592d13031f494674c8c602e624f1d03d /Plugins | |
parent | Began a complete rewrite of command and plugin management. (diff) | |
download | hsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.tar.gz hsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.tar.bz2 hsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.zip |
Continue rewriting, found a problem in the way I kill plugins.
Diffstat (limited to '')
-rw-r--r-- | Plugins/Core.hs | 10 | ||||
-rw-r--r-- | Plugins/Quote.hs | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/Plugins/Core.hs b/Plugins/Core.hs index a15cc62..99abfc0 100644 --- a/Plugins/Core.hs +++ b/Plugins/Core.hs @@ -3,6 +3,7 @@ module Plugins.Core ) where import Control.Concurrent.Chan +import Control.Monad.State import Hsbot.IRCPlugin import Hsbot.Types @@ -18,9 +19,9 @@ mainCore serverChan chan = do -- | The IrcPlugin monad main function run :: IrcPlugin () run = do - mapM_ sendRegisterCommand ["load", "unload"] + mapM_ sendRegisterCommand ["load", "reload", "unload"] runPlugin - mapM_ sendUnregisterCommand ["load", "unload"] + mapM_ sendUnregisterCommand ["load", "reload", "unload"] runPlugin :: IrcPlugin () runPlugin = forever $ do @@ -33,6 +34,7 @@ runPlugin = forever $ do "RUN" -> let stuff = words $ intCmdMsg intCmd in case head stuff of "load" -> loadPlugin $ tail stuff + "reload" -> reloadPlugin $ tail stuff "unload" -> unloadPlugin $ tail stuff _ -> lift $ trace $ show intCmd -- TODO : help message _ -> lift $ trace $ show intCmd @@ -43,6 +45,10 @@ runPlugin = forever $ do loadPlugin :: [String] -> IrcPlugin () loadPlugin pluginNames = mapM_ (sendCommand "LOAD" "CORE") pluginNames +-- | The reload command +reloadPlugin :: [String] -> IrcPlugin () +reloadPlugin pluginNames = mapM_ (sendCommand "RELOAD" "CORE") pluginNames + -- | The unload command unloadPlugin :: [String] -> IrcPlugin () unloadPlugin pluginNames = mapM_ (sendCommand "UNLOAD" "CORE") pluginNames diff --git a/Plugins/Quote.hs b/Plugins/Quote.hs index 4c6e22c..fd36e11 100644 --- a/Plugins/Quote.hs +++ b/Plugins/Quote.hs @@ -28,8 +28,9 @@ type QuoteBot a = StateT QuoteDB IO a mainQuote :: Chan BotMsg -> Chan BotMsg -> IO () mainQuote serverChan chan = do let plugin = PluginInstance "Quote" serverChan chan - (runStateT run plugin) `catch` (const $ return ((), plugin)) - return () + plugin' <- (execStateT run plugin) `catch` (const $ return plugin) + putStrLn "graou" + evalStateT stop plugin' -- | The IrcPlugin monad main function run :: IrcPlugin () @@ -37,6 +38,9 @@ run = do -- TODO : init quote handling (sqlite + structure to handle temporary stuff) sendRegisterCommand "quote" runPlugin + +stop :: IrcPlugin () +stop = do sendUnregisterCommand "quote" -- TODO : send cancel messages for all temporary stuff |