summaryrefslogtreecommitdiff
path: root/Hsbot/Irc/Command.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-05-29 23:48:47 +0200
committerJulien Dessaux2010-05-29 23:55:20 +0200
commit3410caa6f2e1fd74d55f7a1717420bb2e1052b12 (patch)
tree214cb220de340eada4141479ae6415e654a4fdc3 /Hsbot/Irc/Command.hs
parentAdded signal handling and a better semantic for bot status. (diff)
downloadhsbot-3410caa6f2e1fd74d55f7a1717420bb2e1052b12.tar.gz
hsbot-3410caa6f2e1fd74d55f7a1717420bb2e1052b12.tar.bz2
hsbot-3410caa6f2e1fd74d55f7a1717420bb2e1052b12.zip
Fixed the plugin termination.
The master of a plugin will now wait for the plugin it kills to terminate.
Diffstat (limited to 'Hsbot/Irc/Command.hs')
-rw-r--r--Hsbot/Irc/Command.hs15
1 files changed, 9 insertions, 6 deletions
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 ()