Browse Source

some fixes

master
Annwan 3 years ago
parent
commit
6640ecc4e8
  1. 17
      app/Commands/EDT.hs
  2. 6
      app/Commands/Reminds.hs
  3. 12
      app/Main.hs
  4. 2
      stack.yaml

17
app/Commands/EDT.hs

@ -39,7 +39,10 @@ getEdt conf@Config {..} opts = do
(HTTP.getResponseBody cal_req)
dates <- readDate date
tz <- DT.getTimeZone $ DT.UTCTime (head dates) $ DT.secondsToDiffTime 43200
let message = case cal of
let
message =
case
(case cal of
Left _ -> "I don't know this group, alternatively ADE doesn't work"
Right (vcal@IT.VCalendar { IT.vcEvents = evm } : _, _) ->
TS.unlines
@ -50,14 +53,22 @@ getEdt conf@Config {..} opts = do
`TS.append` TS.pack (show d)
`TS.append` "**\n"
`TS.append` renderEvents tz (ev d)
else "No classes for the selected dates"
else ""
)
$ dates
where
ev :: DT.Day -> [IT.VEvent]
ev d =
sortOn IT.veDTStart . filter (inDate d) . map snd . Map.toList $ evm
sortOn IT.veDTStart
. filter (inDate d)
. map snd
. Map.toList
$ evm
_ -> "An unexpected error has occured"
)
of
"" -> "No classes for the selected period"
s -> s
return message
where
group :: TS.Text

6
app/Commands/Reminds.hs

@ -58,9 +58,9 @@ scheduleRemind ev Remind {..} = do
$ restCall
$ CreateMessage rmdChannel
$ "<@"
`T.append` T.pack (show rmdUser)
`T.append` "> **Reminder**\n"
`T.append` rmdMessage
<> T.pack (show rmdUser)
<> "> **Reminder**\n"
<> rmdMessage
registerRemind :: Remind -> IO ()
registerRemind Remind {..} = do

12
app/Main.hs

@ -170,12 +170,12 @@ pushgroupedt conf@Config {..} day glist = do
liftIO
$ TIO.putStrLn
$ "Putting out time table for group "
`T.append` gn
`T.append` " in "
`T.append` T.pack (show gc)
`T.append` ":\n"
`T.append` edt
restCall $ R.CreateMessage gc (edt `T.append` "\nAutomatic time table")
<> gn
<> " in "
<> T.pack (show gc)
<> ":\n"
<> edt
restCall $ R.CreateMessage gc edt
return ()
)
glist

2
stack.yaml

@ -7,7 +7,7 @@ extra-deps:
- emoji-0.1.0.2
- iCalendar-0.4.0.5
- mime-0.4.0.2
- discord-haskell-1.12.1
- discord-haskell-1.12.5
- control-event-1.3
- HDBC-sqlite3-2.3.3.1
## My fork of discord-haskell to PR bug fixes and have them before merge

Loading…
Cancel
Save