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

6
app/Commands/Reminds.hs

@ -58,9 +58,9 @@ scheduleRemind ev Remind {..} = do
$ restCall $ restCall
$ CreateMessage rmdChannel $ 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 -> IO ()
registerRemind Remind {..} = do registerRemind Remind {..} = do

12
app/Main.hs

@ -170,12 +170,12 @@ pushgroupedt conf@Config {..} day glist = do
liftIO liftIO
$ TIO.putStrLn $ TIO.putStrLn
$ "Putting out time table for group " $ "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 () return ()
) )
glist glist

2
stack.yaml

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

Loading…
Cancel
Save