adding rss support + moving data structure logic to the python script
This commit is contained in:
parent
9485ab95b2
commit
6b0fe8ad5a
@ -8,6 +8,7 @@ from urllib.parse import urlparse
|
||||
import jinja2
|
||||
from xbotlib import Bot
|
||||
|
||||
# Functions that are used as Jinja filters
|
||||
|
||||
def _href_wrap(post):
|
||||
"""Wrap links in a tags as a Jinja template filter."""
|
||||
@ -16,6 +17,7 @@ def _href_wrap(post):
|
||||
post = post.replace(url, url_with_href)
|
||||
return post
|
||||
|
||||
# Main Logbot class
|
||||
|
||||
class Logbot(Bot):
|
||||
|
||||
@ -122,12 +124,13 @@ class Logbot(Bot):
|
||||
html = template.render(
|
||||
title=self.db[message.room]["title"],
|
||||
db=self.db[message.room]["messages"],
|
||||
sorted_keys=[str(num) for num in sorted([int(num) for num in self.db[message.room]["messages"].keys()])]
|
||||
)
|
||||
out.write(html)
|
||||
self.log.info(f"writing to: { log_path }")
|
||||
|
||||
def _generate_feed(self, message):
|
||||
template = jinja2.Template(open("feed.rss").read())
|
||||
template = jinja2.Template(open("template.rss").read())
|
||||
folder_name = self.db[message.room]["folder"]
|
||||
if "@" in folder_name: # hacky
|
||||
folder_name = self._parse_room_name(folder_name)
|
||||
|
Loading…
Reference in New Issue
Block a user