minor fixes
This commit is contained in:
parent
42de1efed1
commit
4f25c2dd3f
4
rss.py
4
rss.py
|
@ -9,7 +9,8 @@ class FeedItem:
|
|||
if 'published' in item:
|
||||
self.date = item.published_parsed()
|
||||
else:
|
||||
self.date = ''
|
||||
self.date = None
|
||||
|
||||
|
||||
class Feed:
|
||||
def __init__(self, url: str, feed: FeedParserDict) -> None:
|
||||
|
@ -19,6 +20,7 @@ class Feed:
|
|||
for item in feed.entries:
|
||||
self.items.append(FeedItem(item))
|
||||
|
||||
|
||||
class RssReader:
|
||||
def get_feed(self, url: str) -> Feed:
|
||||
return Feed(url, parse(url))
|
||||
|
|
12
telegram.py
12
telegram.py
|
@ -58,8 +58,8 @@ class CommandProcessor:
|
|||
feeds = self.database.find_user_feeds(data['user_id'])
|
||||
|
||||
feed_list = ''
|
||||
for count, feed in enumerate(feeds, start=1):
|
||||
feed_list += '* ' + str(count) + ': ' + feed['url'] + '\n'
|
||||
for index, feed in enumerate(feeds, start=1):
|
||||
feed_list += '* ' + str(index) + ': ' + f"<a href={feed['url']}>{feed['title']}</a" + '\n'
|
||||
|
||||
self.bot.reply_to(message, 'Your feeds:\n' + feed_list)
|
||||
|
||||
|
@ -90,7 +90,7 @@ class CommandProcessor:
|
|||
class Notifier:
|
||||
"""Sends notifications to users about new RSS feed items."""
|
||||
|
||||
BATCH_LIMIT: int = 30
|
||||
BATCH_LIMIT: int = 29
|
||||
|
||||
sent_counter: int = 0
|
||||
|
||||
|
@ -104,6 +104,8 @@ class Notifier:
|
|||
chat_id=chat_id,
|
||||
text=f'Updates from the {feed_title} feed:'
|
||||
)
|
||||
self.sent_counter += 1
|
||||
|
||||
for update in updates:
|
||||
self.__send_update(chat_id, update)
|
||||
self.sent_counter += 1
|
||||
|
@ -123,8 +125,8 @@ class Notifier:
|
|||
def __format_message(item: FeedItem) -> str:
|
||||
return (
|
||||
f"<strong><a href=\"{item.url}\">{item.title}</a></strong>\n\n"
|
||||
f"{item.description}\n"
|
||||
f"{item.date}"
|
||||
f"{item.date}\n"
|
||||
f"{item.description}"
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue