From 8ecae62901f2112068f52c06535956a60fb81c41 Mon Sep 17 00:00:00 2001 From: Yannik Enss Date: Wed, 23 Dec 2020 18:00:19 +0100 Subject: [PATCH] stuff --- generate.py | 13 ++++++++++++- generator.conf | 4 +++- prepare_presentation.sh | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/generate.py b/generate.py index 1502f42..64118cf 100755 --- a/generate.py +++ b/generate.py @@ -9,6 +9,8 @@ import sys, os import pypandoc import argparse import quopri +import requests +import json from pprint import pprint CONFIG_FILE = "generator.conf" @@ -42,8 +44,9 @@ def get_body_text(msg): class Top: def __init__(self, title=None, sender=None, body=None, protostub=None, message=None): if message: - self.title = decode_header(message["Subject"])[6:] + self.title = decode_header(message["Subject"][6:]) real_name, address = email.utils.parseaddr(message["From"]) + real_name = decode_header(real_name) self.sender = real_name or address payload = get_body_text(message) self.body = str(payload.rpartition("\n--")[0] if "\n--" in payload else payload) @@ -125,10 +128,12 @@ if __name__ == "__main__": parser.add_argument("--config", default=CONFIG_FILE) mode = parser.add_mutually_exclusive_group(required=True) mode.add_argument("--invite", action="store_true") + mode.add_argument("--mm-invite", action="store_true") mode.add_argument("--presentation", action="store_true") mode.add_argument("--protocol", action="store_true") parser.add_argument("--debug", action="store_true", help=argparse.SUPPRESS) parser.add_argument("--write-mbox", action="store_true") + parser.add_argument("--send-mm", action="store_true") args = parser.parse_args() config = yaml.full_load(open(args.config)) @@ -137,6 +142,8 @@ if __name__ == "__main__": template_file = config["invite_template_file"] elif args.presentation: template_file = config["presentation_template_file"] + elif args.mm_invite: + template_file = config["mminvite_template_file"] elif args.protocol: template_file = config["protocol_template_file"] else: @@ -204,5 +211,9 @@ if __name__ == "__main__": mbox.add(msg) mbox.close() print(mbox) + elif args.send_mm: + headers = {'Content-Type': 'application/json',} + values = json.dumps({ "text": template.render(context), "username": "test"}) + response = requests.post(config["mm_url"], headers=headers, data=values) else: print(template.render(context)) diff --git a/generator.conf b/generator.conf index 4c5ea24..2963840 100644 --- a/generator.conf +++ b/generator.conf @@ -3,7 +3,7 @@ redeleitung: email: yannik.enss@fsmi.uni-karlsruhe.de protokoll: - name: Alina Valta + name: Tobias Wiese pre_tops: - title: Begrüßung @@ -48,6 +48,7 @@ post_tops: - title: Sonstiges invite_template_file: templates/fsr_einladung.j2 +mminvite_template_file: templates/fsr_einladung_mm.j2 presentation_template_file: templates/fsr_presentation.tex.j2 protocol_template_file: templates/fsr_protokoll.j2 @@ -63,5 +64,6 @@ place: Big Blue Button invite_mail: fsr-einladung@fsmi.uni-karlsruhe.de invite_subject: 'Einladung zum Fachschaftsrat am {{date|weekday}}, dem {{date|date}}' +mm_url: https://mattermost.fsmi.uni-karlsruhe.de/hooks/xpqbpuxug3fsin5zwpcbuu11ky # vim: filetype=yaml diff --git a/prepare_presentation.sh b/prepare_presentation.sh index 0ceb74a..0725105 100755 --- a/prepare_presentation.sh +++ b/prepare_presentation.sh @@ -3,3 +3,8 @@ ./read_ubmails.py ./generate.py --presentation > data/presentation_$(date +%Y-%m-%d).tex +cd data/presentation/ +pdflatex ../presentation_$(date +%Y-%m-%d).tex +pdflatex ../presentation_$(date +%Y-%m-%d).tex +pdflatex ../presentation_$(date +%Y-%m-%d).tex +