summaryrefslogtreecommitdiff
path: root/Hsbot/Command.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-04-22 19:42:53 +0200
committerJulien Dessaux2010-04-22 19:42:53 +0200
commit727adadc28a40fe8843a0727168684d3c2b3e114 (patch)
tree03af9d78502488676c74d1f55762c5c6b6de2116 /Hsbot/Command.hs
parentWrote the list plugin command. (diff)
downloadhsbot-727adadc28a40fe8843a0727168684d3c2b3e114.tar.gz
hsbot-727adadc28a40fe8843a0727168684d3c2b3e114.tar.bz2
hsbot-727adadc28a40fe8843a0727168684d3c2b3e114.zip
Added an utility function to correctly answer a message we receive (aka /msg)
Diffstat (limited to '')
-rw-r--r--Hsbot/Command.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Hsbot/Command.hs b/Hsbot/Command.hs
index ea372e4..711aa32 100644
--- a/Hsbot/Command.hs
+++ b/Hsbot/Command.hs
@@ -38,16 +38,16 @@ unregisterCommand cmd pluginName' = do
-- | Dispatches an input message
dispatchMessage :: BotMsg -> IrcBot ()
-dispatchMessage (InputMsg inputMsg) = do
- plugins <- gets botPlugins
- cmds <- gets botCommands
- if isPluginCommand --TODO : how to get rid of this if?
- then
+dispatchMessage (InputMsg inputMsg)
+ | isPluginCommand = do
+ plugins <- gets botPlugins
+ cmds <- gets botCommands
let key = tail $ head $ words getMsgContent
pluginNames = fromMaybe [] $ M.lookup key cmds
plugins' = fromMaybe [] $ mapM (flip M.lookup plugins) pluginNames
- in mapM_ (sendRunCommand $ tail getMsgContent) plugins'
- else
+ mapM_ (sendRunCommand $ tail getMsgContent) plugins'
+ | otherwise = do
+ plugins <- gets botPlugins
mapM_ (sendToPlugin (InputMsg inputMsg)) (M.elems plugins)
where
isPluginCommand :: Bool