Archived
1
0
Fork 0

Fixed a bug in command parsing

This commit is contained in:
Julien Dessaux 2011-06-17 13:07:25 +02:00
parent 066b271510
commit 336ec59689

View file

@ -30,12 +30,15 @@ answerMsg _ _ = return ()
-- | Get the command in the IRC message if there is one -- | Get the command in the IRC message if there is one
getCommand :: IRC.Message -> Env IO [String] getCommand :: IRC.Message -> Env IO [String]
getCommand (IRC.Message _ _ (_:msg:[])) = do getCommand (IRC.Message _ _ (_:msg:[])) = getCommandFrom $ words msg
currentBotState <- asks envBotState >>= liftIO . readMVar where
let cmd:stuff = if msg /= "" then words msg else ["",""] getCommandFrom :: [String] -> Env IO [String]
if botNickname currentBotState `L.isPrefixOf` cmd getCommandFrom (cmd:stuff) = do
then return stuff currentBotState <- asks envBotState >>= liftIO . readMVar
else return [] if botNickname currentBotState `L.isPrefixOf` cmd
then return stuff
else return []
getCommandFrom _ = return []
getCommand _ = return [] getCommand _ = return []
getSender :: IRC.Message -> String getSender :: IRC.Message -> String