Merge branch 'messages' into master

This commit is contained in:
Adam Blažek 2020-09-29 09:12:03 +02:00
commit ecdce60091
1 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import json, net, options, os, strscans, times, unicode, uri
from strutils import ffDecimal, formatFloat
import htmlparser, json, net, options, os, strscans, times, unicode, uri, xmltree
from strutils import ffDecimal, formatFloat, replace
import cligen, colorize, elvis
from bakalari as baka import Grade, newBakalari
@ -106,6 +106,17 @@ proc homework(
stdout.writeLine homework.teacher.fgLightMagenta
stdout.writeLine homework.content
proc messages(
configFile = defaultConfigFile,
) =
withBakalari(defaultConfigFile):
for message in baka.messages(bakalari):
stdout.writeLine "----------------------------------------------------------------".fgLightGray
stdout.writeLine message.sentTime.format("yyyy-MM-dd") .fgLightCyan
stdout.writeLine message.title.fgLightYellow
stdout.writeLine message.sender.fgLightMagenta
stdout.writeLine message.text.replace("<br />", "{{br}}").parseHtml.innerText.replace("{{br}}", "\n")
proc timetable(
configFile = defaultConfigFile,
date = "",
@ -159,6 +170,9 @@ try:
[homework, help = {
"config-file": "where the credentials are stored",
}],
[messages, help = {
"config-file": "where the credentials are stored",
}],
[timetable, help = {
"config-file": "where the credentials are stored",
"date": "any date inside the week you want to display, in YYYYMMDD format (defaults to today)",