Fix representation date in FeedItem (#38)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #38 Reviewed-by: Alexey Skobkin <skobkin-ru@ya.ru>
This commit is contained in:
parent
6ac2610637
commit
92ced4c91b
|
@ -37,3 +37,10 @@ export TELEGRAM_TOKEN=xxx
|
|||
export DATABASE_PATH=./database.db
|
||||
python bot.py
|
||||
```
|
||||
## Running the update
|
||||
|
||||
```shell
|
||||
export TELEGRAM_TOKEN=xxx
|
||||
export DATABASE_PATH=./database.db
|
||||
python update.py
|
||||
```
|
5
rss.py
5
rss.py
|
@ -1,5 +1,6 @@
|
|||
from logging import Logger
|
||||
|
||||
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 = item.published_parsed
|
||||
self.date = datetime.fromtimestamp(mktime(item.published_parsed))
|
||||
else:
|
||||
self.date = None
|
||||
|
||||
|
|
|
@ -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,8 +163,8 @@ class Notifier:
|
|||
|
||||
def __format_message(self, item: FeedItem) -> str:
|
||||
return (
|
||||
# TODO: Return date when FeedItem starts to return formattable datetime object
|
||||
f"<strong><a href=\"{item.url}\">{item.title}</a></strong>\n\n"
|
||||
f"<strong><a href=\"{item.url}\">{item.title}</a></strong>\n"
|
||||
f"{item.date.strftime('%m.%d.%Y %H:%M')}\n\n"
|
||||
f"{self.__sanitize_html(item.description)}"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue