mirror of https://github.com/stijndcl/didier
Add markdown support for ufora notifications, store notifications using IDs
parent
c9bef3b300
commit
268bb80bfd
|
@ -26,6 +26,9 @@ class UforaNotification:
|
|||
|
||||
return embed
|
||||
|
||||
def get_id(self):
|
||||
return int(self._notif_id) if self._notif_id is not None else self._content["id"]
|
||||
|
||||
def _create_url(self):
|
||||
if self._notif_id is None or self._course_id is None:
|
||||
return self._content["link"]
|
||||
|
@ -52,11 +55,27 @@ class UforaNotification:
|
|||
|
||||
def _clean_content(self, text: str):
|
||||
html_table = {
|
||||
# CHARACTERS:
|
||||
"&": '&',
|
||||
""": '"',
|
||||
"apos;": "'",
|
||||
">": ">",
|
||||
"<": "<"
|
||||
"<": "<",
|
||||
# MARKDOWN SUPPORT:
|
||||
"<b>": "**",
|
||||
"</b>": "**",
|
||||
"<strong>": "**",
|
||||
"</strong>": "**",
|
||||
"<i>": "*",
|
||||
"</i>": "*",
|
||||
"<em>": "*",
|
||||
"</em>": "*",
|
||||
"<del>": "~~",
|
||||
"</del>": "~~",
|
||||
"<ins>": "__",
|
||||
"</ins>": "__",
|
||||
# Represent paragraphs with newlines
|
||||
"</p>": "\n"
|
||||
}
|
||||
|
||||
# Unescape HTML
|
||||
|
|
|
@ -41,9 +41,10 @@ def run():
|
|||
|
||||
if feed:
|
||||
for item in feed:
|
||||
notifications[course].append(item["id"])
|
||||
notification = UforaNotification(item, course)
|
||||
new_notifications.append(notification)
|
||||
|
||||
new_notifications.append(UforaNotification(item, course))
|
||||
notifications[course].append(notification.get_id())
|
||||
|
||||
# Update list of notifications
|
||||
if new_notifications:
|
||||
|
|
Loading…
Reference in New Issue