Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/Bot/Asciify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ currentAsciifyState = do
Just state -> return state
Nothing -> createEntity Proxy =<< AsciifyState <$> now

asciifyCooldown :: Reaction Message a -> Reaction Message a
asciifyCooldown next =
asciifyCooldown :: NominalDiffTime -> Reaction Message a -> Reaction Message a
asciifyCooldown cooldown next =
Reaction $ \msg -> do
state <- currentAsciifyState
currentTime <- now
let diff =
diffUTCTime currentTime $ asciifyStateLastUsed $ entityPayload state
let cooldown = 2 * 60
if diff > cooldown
then do
void $ updateEntityById $ AsciifyState currentTime <$ state
Expand All @@ -69,7 +68,7 @@ asciifyReaction =
bttv <- bttvUrlByName name
return (ffz <|> bttv)) $
replyOnNothing "Such emote does not exist" $
asciifyCooldown $
asciifyCooldown 60 $
byteStringHttpRequestReaction $
cmapR (braillizeByteString . BSL.toStrict) $
eitherReaction (Reaction (logMsg . T.pack . messageContent)) $
Expand Down