Created
July 2, 2018 17:26
-
-
Save Ranlvor/376d43248c9dbec00469d5d207d62498 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# -*- coding: UTF-8 -*- | |
##### | |
# | |
# Plenum-Reminder, by Ranlvor | |
# with idea and large code-parts taken from Kunsi https://github.com/entropia/reminders/blob/master/plenum.py | |
# | |
# To be executed by a cronjob whenever the reminder should be sent | |
# | |
# sends out a mail notification to the mailing list about a plenum next sunday. | |
# | |
##### | |
import requests | |
import datetime | |
import smtplib | |
import locale | |
from email.mime.text import MIMEText | |
def find_between( s, first, last ): | |
try: | |
start = s.index(first) + len(first) | |
end = s.index(last, start) | |
return s[start:end] | |
except ValueError: | |
return None | |
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8') | |
wiki = requests.get("https://wiki.raumzeitlabor.de/wiki/Plenum?action=edit") | |
wikisource = wiki.content.decode('utf-8') | |
key_start = '= Themen für das nächste Plenum =' | |
key_end = '[[Kategorie:Veranstaltung]]' | |
plenum_tops = find_between(wikisource, key_start, key_end).strip() | |
msg = MIMEText("""Hi, | |
nächste Woche ist mal wieder erster Sonnag im Monat. Das heißt es gibt | |
wieder Plenum und Wipe and Defrag. Komm zum RaumZeitLabor zum Räumen | |
und Plenieren ab 14:00. | |
Das Wiki hat folgende Punkte notiert: | |
""" + plenum_tops + """ | |
Gruß | |
Ein kleines Python-Skript auf dem Server von Ranlvor""") | |
msg['Subject'] = '[RaumZeitLabor] Reminder: Wipe and Defrag & Plenum nächsten Sonntag' | |
msg['From'] = '' | |
msg['To'] = '' | |
smtpObj = smtplib.SMTP('localhost') | |
smtpObj.send_message(msg) | |
smtpObj.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment