summaryrefslogtreecommitdiff
path: root/Hsbot/Command.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-02-04 23:34:15 +0100
committerJulien Dessaux2010-02-04 23:34:15 +0100
commit416460886da9f8d835200ca46c9062a4ebd78fe7 (patch)
treef76663fd592d13031f494674c8c602e624f1d03d /Hsbot/Command.hs
parentBegan a complete rewrite of command and plugin management. (diff)
downloadhsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.tar.gz
hsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.tar.bz2
hsbot-416460886da9f8d835200ca46c9062a4ebd78fe7.zip
Continue rewriting, found a problem in the way I kill plugins.
Diffstat (limited to 'Hsbot/Command.hs')
-rw-r--r--Hsbot/Command.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/Hsbot/Command.hs b/Hsbot/Command.hs
index 054653d..76f1d04 100644
--- a/Hsbot/Command.hs
+++ b/Hsbot/Command.hs
@@ -67,7 +67,9 @@ processInternalCommand (InternalCmd intCmd) = do
plugins <- gets botPlugins
if intCmdTo intCmd == "CORE"
then processCoreCommand intCmd
- else sendToPlugin (InternalCmd intCmd) $ fromMaybe [] (M.lookup plugins (intCmdTo intCmd))
+ else case M.lookup (intCmdTo intCmd) plugins of
+ Just plugin -> sendToPlugin (InternalCmd intCmd) plugin
+ Nothing -> errorM $ "Invalid destination in message : " ++ (show intCmd)
processInternalCommand _ = return ()
-- | Processes a core command
@@ -76,8 +78,11 @@ processCoreCommand intCmd = do
let command' = intCmdCmd intCmd
case command' of
"LOAD" -> loadPlugin $ intCmdMsg intCmd
+ "RELOAD" -> reloadPlugin $ intCmdMsg intCmd
"UNLOAD" -> unloadPlugin $ intCmdMsg intCmd
"REGISTER" -> registerCommand (intCmdMsg intCmd) (intCmdFrom intCmd)
"UNREGISTER" -> unregisterCommand (intCmdMsg intCmd) (intCmdFrom intCmd)
_ -> traceM $ inColor ("Invalid command : " ++ (show intCmd)) [31]
+ bot' <- get
+ traceM $ show bot'