From 3410caa6f2e1fd74d55f7a1717420bb2e1052b12 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 29 May 2010 23:48:47 +0200 Subject: Fixed the plugin termination. The master of a plugin will now wait for the plugin it kills to terminate. --- Hsbot/Irc/Command.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Hsbot/Irc/Command.hs') diff --git a/Hsbot/Irc/Command.hs b/Hsbot/Irc/Command.hs index 242e12d..51c2187 100644 --- a/Hsbot/Irc/Command.hs +++ b/Hsbot/Irc/Command.hs @@ -12,6 +12,7 @@ import Data.Maybe import Hsbot.Irc.Message import Hsbot.Irc.Plugin import Hsbot.Irc.Types +import Hsbot.Types -- | Registers a plugin's command registerCommand :: String -> String -> IrcBot () @@ -34,19 +35,19 @@ unregisterCommand cmd pluginName' = do put $ ircBot { ircBotCommands = newCmds } -- | Processes an internal command -processInternalCommand :: IrcBotMsg -> IrcBot (Bool) +processInternalCommand :: IrcBotMsg -> IrcBot (BotStatus) processInternalCommand (IntIrcCmd ircCmd) | ircCmdTo ircCmd == "CORE" = processCoreCommand ircCmd | otherwise = do plugins <- gets ircBotPlugins case M.lookup (ircCmdTo ircCmd) plugins of - Just (plugin, _) -> sendToPlugin (IntIrcCmd ircCmd) plugin + Just (plugin, _, _) -> sendToPlugin (IntIrcCmd ircCmd) plugin Nothing -> return () - return False -processInternalCommand _ = return (False) + return BotContinue +processInternalCommand _ = return (BotContinue) -- | Processes a core command -processCoreCommand :: IrcCmd -> IrcBot (Bool) +processCoreCommand :: IrcCmd -> IrcBot (BotStatus) processCoreCommand ircCmd = do let command' = ircCmdCmd ircCmd originalRequest = ircCmdBotMsg ircCmd @@ -58,7 +59,9 @@ processCoreCommand ircCmd = do "UNREGISTER" -> unregisterCommand (ircCmdMsg ircCmd) (ircCmdFrom ircCmd) "UPDATE" -> processUpdateCommand ircCmd _ -> return () - return $ command' == "REBOOT" + if command' == "REBOOT" + then return BotReboot + else return BotContinue -- | Process an update command processUpdateCommand :: IrcCmd -> IrcBot () -- cgit v1.2.3