summaryrefslogtreecommitdiff
path: root/Hsbot
diff options
context:
space:
mode:
authorJulien Dessaux2011-06-17 13:07:25 +0200
committerJulien Dessaux2011-06-17 13:07:25 +0200
commit336ec596894a41cb0fa55fd9e1a76f6f62c9364f (patch)
tree4c303a3007d30c2f7e829fb407140c81cd1d5bbb /Hsbot
parentSimplified and greatly improved scoring for the duck game. (diff)
downloadhsbot-336ec596894a41cb0fa55fd9e1a76f6f62c9364f.tar.gz
hsbot-336ec596894a41cb0fa55fd9e1a76f6f62c9364f.tar.bz2
hsbot-336ec596894a41cb0fa55fd9e1a76f6f62c9364f.zip
Fixed a bug in command parsing
Diffstat (limited to '')
-rw-r--r--Hsbot/Message.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/Hsbot/Message.hs b/Hsbot/Message.hs
index 14488a1..a34659d 100644
--- a/Hsbot/Message.hs
+++ b/Hsbot/Message.hs
@@ -30,12 +30,15 @@ answerMsg _ _ = return ()
-- | Get the command in the IRC message if there is one
getCommand :: IRC.Message -> Env IO [String]
-getCommand (IRC.Message _ _ (_:msg:[])) = do
- currentBotState <- asks envBotState >>= liftIO . readMVar
- let cmd:stuff = if msg /= "" then words msg else ["",""]
- if botNickname currentBotState `L.isPrefixOf` cmd
- then return stuff
- else return []
+getCommand (IRC.Message _ _ (_:msg:[])) = getCommandFrom $ words msg
+ where
+ getCommandFrom :: [String] -> Env IO [String]
+ getCommandFrom (cmd:stuff) = do
+ currentBotState <- asks envBotState >>= liftIO . readMVar
+ if botNickname currentBotState `L.isPrefixOf` cmd
+ then return stuff
+ else return []
+ getCommandFrom _ = return []
getCommand _ = return []
getSender :: IRC.Message -> String