From 468da6b5ee769fbe2bede4a4c6bcbd73e638cdcd Mon Sep 17 00:00:00 2001 From: mitsuha_s Date: Sun, 10 Jul 2022 15:26:54 +0000 Subject: [PATCH 1/5] add documentation for running updater in README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index be1998b..cbf3962 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,8 @@ export TELEGRAM_TOKEN=xxx export DATABASE_PATH=./database.db python bot.py ``` +## Running the update + +```shell +python update.py +``` \ No newline at end of file -- 2.43.5 From f101f825a3aeaa38490b30ab1385941d488fcbe9 Mon Sep 17 00:00:00 2001 From: mitsuha_s Date: Sun, 10 Jul 2022 16:10:52 +0000 Subject: [PATCH 2/5] fix representation date in FeedItem --- rss.py | 4 ++-- telegram.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rss.py b/rss.py index eeeaa01..fa39cce 100644 --- a/rss.py +++ b/rss.py @@ -1,5 +1,5 @@ from logging import Logger - +from time import strftime from feedparser import FeedParserDict, parse @@ -9,7 +9,7 @@ class FeedItem: self.title = item.get('title', '') self.description = item.get('summary', '') if 'published' in item: - self.date = item.published_parsed + self.date = strftime("%d.%m.%Y %H:%M", item.published_parsed) else: self.date = None diff --git a/telegram.py b/telegram.py index 7860b45..d43a92a 100644 --- a/telegram.py +++ b/telegram.py @@ -165,7 +165,8 @@ class Notifier: def __format_message(self, item: FeedItem) -> str: return ( # TODO: Return date when FeedItem starts to return formattable datetime object - f"{item.title}\n\n" + f"{item.title}\n" + f"{item.date}\n\n" f"{self.__sanitize_html(item.description)}" ) -- 2.43.5 From 7939babbe0a06fb50776ef9ceda4578924864de8 Mon Sep 17 00:00:00 2001 From: mitsuha_s Date: Sun, 10 Jul 2022 16:29:23 +0000 Subject: [PATCH 3/5] little code style fixes --- telegram.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/telegram.py b/telegram.py index d43a92a..bab8e58 100644 --- a/telegram.py +++ b/telegram.py @@ -1,7 +1,6 @@ import time - -from bleach.sanitizer import Cleaner from logging import Logger +from bleach.sanitizer import Cleaner from telebot import TeleBot from telebot.handler_backends import BaseMiddleware from telebot.types import Message @@ -164,7 +163,6 @@ class Notifier: def __format_message(self, item: FeedItem) -> str: return ( - # TODO: Return date when FeedItem starts to return formattable datetime object f"{item.title}\n" f"{item.date}\n\n" f"{self.__sanitize_html(item.description)}" -- 2.43.5 From c65dfc62a44d2ae8c8f630eb0ef781da98ea517f Mon Sep 17 00:00:00 2001 From: mitsuha_s Date: Sun, 10 Jul 2022 17:29:31 +0000 Subject: [PATCH 4/5] use datetime.datetime instead of time.struct_time --- rss.py | 5 +++-- telegram.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rss.py b/rss.py index fa39cce..d591843 100644 --- a/rss.py +++ b/rss.py @@ -1,5 +1,6 @@ from logging import Logger -from time import strftime +from datetime import datetime +from time import mktime from feedparser import FeedParserDict, parse @@ -9,7 +10,7 @@ class FeedItem: self.title = item.get('title', '') self.description = item.get('summary', '') if 'published' in item: - self.date = strftime("%d.%m.%Y %H:%M", item.published_parsed) + self.date = datetime.fromtimestamp(mktime(item.published_parsed)) else: self.date = None diff --git a/telegram.py b/telegram.py index bab8e58..27e44dd 100644 --- a/telegram.py +++ b/telegram.py @@ -164,7 +164,7 @@ class Notifier: def __format_message(self, item: FeedItem) -> str: return ( f"{item.title}\n" - f"{item.date}\n\n" + f"{item.date.strftime('%m.%d.%Y %H:%M')}\n\n" f"{self.__sanitize_html(item.description)}" ) -- 2.43.5 From bbb91ca033a9f2592f32df4408f2deeb2bdeac87 Mon Sep 17 00:00:00 2001 From: mitsuha_s Date: Sun, 10 Jul 2022 17:32:30 +0000 Subject: [PATCH 5/5] add env variables in running the update documentation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cbf3962..2439a59 100644 --- a/README.md +++ b/README.md @@ -40,5 +40,7 @@ python bot.py ## Running the update ```shell +export TELEGRAM_TOKEN=xxx +export DATABASE_PATH=./database.db python update.py ``` \ No newline at end of file -- 2.43.5