diff options
author | Laura <the-ceo-of-antifa@protonmail.com> | 2023-01-26 23:23:06 +0100 |
---|---|---|
committer | Laura <the-ceo-of-antifa@protonmail.com> | 2023-01-26 23:23:06 +0100 |
commit | 9d31763ebda82ee78652575f47c4fac0eb668daa (patch) | |
tree | 791e4c983e49b3191025126989205f75cb148f3f /miaowe.hs | |
parent | ae5a054c4fc3697ab0026955225db7ceeeb36ead (diff) | |
download | miaowe-9d31763ebda82ee78652575f47c4fac0eb668daa.tar.gz miaowe-9d31763ebda82ee78652575f47c4fac0eb668daa.zip |
Don't reset timer when command is rejected.
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 |