diff options
Diffstat (limited to 'miaowe.hs')
-rw-r--r-- | miaowe.hs | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -251,16 +251,22 @@ doCommand channel command = trySendFile channel ((words command)!!4)) -processCommand :: IrcChannel -> MircString -> NominalDiffTime -> IO () +subtractPresent :: NominalDiffTime -> IO UTCTime +subtractPresent t = getCurrentTime >>= \c -> return $ addUTCTime (-t) c + +processCommand :: IrcChannel -> MircString -> NominalDiffTime -> IO UTCTime processCommand channel command timeElapsed | timeElapsed < 30 = sendToChannel channel "Not so quick, partner" + >> subtractPresent timeElapsed | length (words command) < 5 = sendToChannel channel "You need to specify \ a command." + >> subtractPresent timeElapsed | otherwise = doCommand channel command + >> getCurrentTime commandChannel :: String -> String commandChannel command = (words command)!!2 @@ -270,9 +276,9 @@ mainLoop channel time = waitForCommand >>= \line -> (if commandChannel line == channel then getCurrentTime - >>= \t -> processCommand channel line (diffUTCTime t time) - else return ()) - >> getCurrentTime + >>= \t -> processCommand channel line + (diffUTCTime t time) + else return time) >>= mainLoop channel |