From d922240e9a28680d48014604576620d7fc5aa605 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 22 Apr 2010 00:05:35 +0200 Subject: Wrote the list plugin command. --- Plugins/Core.hs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'Plugins/Core.hs') 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 -- cgit v1.2.3