diff options
-rw-r--r-- | miaowe.hs | 33 |
1 files changed, 21 insertions, 12 deletions
@@ -24,6 +24,7 @@ import qualified Data.ByteString.Char8 as S.Char8 import qualified Data.ByteString.Internal as S.Internal import Data.Char import Data.List +import Data.Time import Data.Word import System.Directory import System.Environment @@ -250,22 +251,29 @@ doCommand channel command = trySendFile channel ((words command)!!4)) -processCommand :: IrcChannel -> MircString -> IO () -processCommand channel command | length (words command) < 5 = sendToChannel channel - "You need to specify \ +processCommand :: IrcChannel -> MircString -> NominalDiffTime -> IO () +processCommand channel command timeElapsed | timeElapsed < 30 = + sendToChannel channel + "Not so quick, partner" + | length (words command) < 5 = + sendToChannel channel + "You need to specify \ a command." - | otherwise = doCommand channel command + | otherwise = + doCommand channel command commandChannel :: String -> String commandChannel command = (words command)!!2 -mainLoop :: IrcChannel -> IO () -mainLoop channel = waitForCommand - >>= \line -> - (if commandChannel line == channel - then processCommand channel line - else return ()) - >> mainLoop channel +mainLoop :: IrcChannel -> UTCTime -> IO () +mainLoop channel time = waitForCommand + >>= \line -> + (if commandChannel line == channel + then getCurrentTime + >>= \t -> processCommand channel line (diffUTCTime t time) + else return ()) + >> getCurrentTime + >>= mainLoop channel main :: IO () @@ -282,4 +290,5 @@ main = >>= \args -> joinChannel (args!!0) >> hFlush stdout - >> mainLoop (args!!0) + >> getCurrentTime + >>= mainLoop (args!!0) |