From 08b2d216ee4d6f951d844bd6774d3cc11ab7a082 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sun, 25 Jun 2023 19:37:52 +0300 Subject: [PATCH] Fix #47. --- rss.py | 4 +++- telegram.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rss.py b/rss.py index 74cd94f..b29065a 100644 --- a/rss.py +++ b/rss.py @@ -10,7 +10,9 @@ class FeedItem: self.title = item.get('title', '') self.description = item.get('summary', '') self.guid = item.get('id', '') - if 'published' in item: + if 'updated' in item: + self.date = datetime.fromtimestamp(mktime(item.updated_parsed)) + elif 'published' in item: self.date = datetime.fromtimestamp(mktime(item.published_parsed)) else: self.date = None diff --git a/telegram.py b/telegram.py index 63f783e..63bce71 100644 --- a/telegram.py +++ b/telegram.py @@ -163,9 +163,13 @@ class Notifier: self.sent_counter += 1 def __format_message(self, item: FeedItem) -> str: + date_string = '' + if item.date is not None: + date_string = item.date.strftime('%m.%d.%Y %H:%M') + return ( f"{item.title}\n" - f"{item.date.strftime('%m.%d.%Y %H:%M')}\n\n" + f"{date_string}\n\n" f"{self.__sanitize_html(item.description)}" )