diff options
author | Julien Dessaux | 2011-09-10 00:10:00 +0200 |
---|---|---|
committer | Julien Dessaux | 2011-09-10 00:10:00 +0200 |
commit | 900c242551f624f4ab5b3ea79fd51611b47bd95e (patch) | |
tree | 215be6ae5c35f08eaa1be497b504abc0b28ee7c6 /Hsbot/Message.hs | |
parent | Fixed compilation errors. Since I forgot to add the quote module to cabal the... (diff) | |
parent | Added score sorting for the duck module (diff) | |
download | hsbot-900c242551f624f4ab5b3ea79fd51611b47bd95e.tar.gz hsbot-900c242551f624f4ab5b3ea79fd51611b47bd95e.tar.bz2 hsbot-900c242551f624f4ab5b3ea79fd51611b47bd95e.zip |
Merge branch 'master' into quoteModule
Conflicts:
hsbot.cabal
Diffstat (limited to 'Hsbot/Message.hs')
-rw-r--r-- | Hsbot/Message.hs | 15 |
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 |