diff options
author | Julien Dessaux | 2010-04-22 00:05:35 +0200 |
---|---|---|
committer | Julien Dessaux | 2010-04-22 00:10:13 +0200 |
commit | d922240e9a28680d48014604576620d7fc5aa605 (patch) | |
tree | 60185f299eebb04d8da9b79e9afd011d6147e411 /Plugins/Core.hs | |
parent | Make the main thread exit cleanly in case of connection loss. (diff) | |
download | hsbot-d922240e9a28680d48014604576620d7fc5aa605.tar.gz hsbot-d922240e9a28680d48014604576620d7fc5aa605.tar.bz2 hsbot-d922240e9a28680d48014604576620d7fc5aa605.zip |
Wrote the list plugin command.
Diffstat (limited to 'Plugins/Core.hs')
-rw-r--r-- | Plugins/Core.hs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Plugins/Core.hs b/Plugins/Core.hs index 123d2e6..64e0bf7 100644 --- a/Plugins/Core.hs +++ b/Plugins/Core.hs @@ -5,6 +5,7 @@ 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 @@ -28,16 +29,27 @@ run = forever $ do eval :: BotMsg -> IrcPlugin () eval (InternalCmd intCmd) = do case intCmdCmd intCmd of - "RUN" -> let stuff = words $ intCmdMsg intCmd - in case head stuff of + "RUN" -> let stuff = words $ intCmdMsg intCmd + request = intCmdBotMsg intCmd + in case head stuff of + "list" -> listPlugins request "load" -> loadPlugin $ tail stuff "reload" -> reloadPlugin $ tail stuff "unload" -> unloadPlugin $ tail stuff _ -> lift $ trace $ show intCmd -- TODO : help message - _ -> lift $ trace $ show intCmd - eval (InputMsg msg) = return () + "ANSWER" -> let stuff = intCmdMsg intCmd + request = intCmdBotMsg intCmd + chanOrigin = head $ parameters (fromMaybe (IrcMsg Nothing "ARGH" []) request) + in writeMsg $ OutputMsg $ IrcMsg Nothing "PRIVMSG" [chanOrigin, "Loaded plugins : " ++ stuff] + _ -> lift $ trace $ show intCmd + eval (InputMsg _) = return () eval _ = return () +-- | The list command +listPlugins :: Maybe IrcMsg -> IrcPlugin () +listPlugins request = do + sendCommandWithRequest "LIST" "CORE" (unwords []) request + -- | The load command loadPlugin :: [String] -> IrcPlugin () loadPlugin pluginNames = mapM_ (sendCommand "LOAD" "CORE") pluginNames |