summaryrefslogtreecommitdiff
path: root/Plugins/Core.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-04-25 16:43:01 +0200
committerJulien Dessaux2010-04-25 16:43:01 +0200
commitb6d119cf5b14fd7198552e939d8f49b15307e74e (patch)
tree1f2188a89b159d6800ff89ed3346437aebfb2782 /Plugins/Core.hs
parentAdded an utility function to correctly answer a message we receive (aka /msg) (diff)
downloadhsbot-b6d119cf5b14fd7198552e939d8f49b15307e74e.tar.gz
hsbot-b6d119cf5b14fd7198552e939d8f49b15307e74e.tar.bz2
hsbot-b6d119cf5b14fd7198552e939d8f49b15307e74e.zip
Some refactoring + cosmetics.
Diffstat (limited to 'Plugins/Core.hs')
-rw-r--r--Plugins/Core.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/Plugins/Core.hs b/Plugins/Core.hs
index f6bd4ef..f81f4bf 100644
--- a/Plugins/Core.hs
+++ b/Plugins/Core.hs
@@ -5,7 +5,6 @@ module Plugins.Core
import Control.Concurrent.Chan(Chan)
import Control.Exception
import Control.Monad.State
-import Data.Maybe(fromMaybe)
import Prelude hiding (catch)
import Hsbot.IRCPlugin
@@ -15,7 +14,7 @@ import Hsbot.Utils
-- | The plugin's main entry point
mainCore :: Chan BotMsg -> Chan BotMsg -> IO ()
mainCore serverChan chan = do
- let plugin = PluginInstance "Core" serverChan chan
+ let plugin = PluginState "Core" serverChan chan
evalStateT (mapM_ sendRegisterCommand ["list", "load", "reload", "unload"]) plugin
plugin' <- (execStateT run plugin) `catch` (\(_ :: AsyncException) -> return plugin)
evalStateT (mapM_ sendUnregisterCommand ["list", "load", "reload", "unload"]) plugin'
@@ -36,15 +35,15 @@ run = forever $ do
"load" -> loadPlugin $ tail stuff
"reload" -> reloadPlugin $ tail stuff
"unload" -> unloadPlugin $ tail stuff
- _ -> lift $ trace $ show intCmd -- TODO : help message
+ _ -> lift . trace $ show intCmd -- TODO : help message
"ANSWER" -> let stuff = intCmdMsg intCmd
in answerMsg request ("Loaded plugins : " ++ stuff)
- _ -> lift $ trace $ show intCmd
+ _ -> lift . trace $ show intCmd
eval (InputMsg _) = return ()
eval _ = return ()
-- | The list command
-listPlugins :: Maybe IrcMsg -> IrcPlugin ()
+listPlugins :: IrcMsg -> IrcPlugin ()
listPlugins request = do
sendCommandWithRequest "LIST" "CORE" (unwords []) request