Browse Source

Fixed all reminds of previous session being resent at startup

master
Antoine COMBET 3 years ago
parent
commit
906ec4bfc3
  1. 7
      app/Main.hs

7
app/Main.hs

@ -38,6 +38,7 @@ import Commands.EDT (getEdt)
import qualified Control.Concurrent
import qualified Control.Event as E
import UnliftIO.Directory (doesFileExist, removeFile)
import Data.Time (getCurrentTime)
main :: IO ()
main = do
@ -75,9 +76,11 @@ onDiscordStart conf eventSystem = do
remindfile <- liftIO $ readFile "reminds.data"
let reminddata :: [Remind]
reminddata = map read $ lines remindfile
now <- liftIO getCurrentTime
mapM_ (\r -> do
withRunInIO $ \runInIO ->
E.addEvent eventSystem (rmdWhen r)
if now > rmdWhen r then
void $ E.addEvent eventSystem (rmdWhen r)
( do
runInIO ( restCall
$ R.CreateMessage (rmdWhere r)
@ -88,6 +91,8 @@ onDiscordStart conf eventSystem = do
)
return ()
)
else
pure ()
) reminddata
liftIO $ removeFile "reminds.data"

Loading…
Cancel
Save