Readd feed to send_to_discord so test passes

This commit is contained in:
2022-12-21 01:51:47 +01:00
parent 965f3008a2
commit f4f9bc1058

View File

@ -32,7 +32,7 @@ from discord_rss_bot.settings import get_reader
from discord_rss_bot.whitelist import has_white_tags, if_in_whitelist from discord_rss_bot.whitelist import has_white_tags, if_in_whitelist
def send_to_discord(custom_reader: Reader | None = None, do_once=False) -> None: def send_to_discord(custom_reader: Reader | None = None, feed=None, do_once=False) -> None:
""" """
Send entries to Discord. Send entries to Discord.
@ -40,6 +40,7 @@ def send_to_discord(custom_reader: Reader | None = None, do_once=False) -> None:
Args: Args:
custom_reader: If we should use a custom reader instead of the default one. custom_reader: If we should use a custom reader instead of the default one.
feed: The feed to send to Discord.
do_once: If we should only send one entry. This is used in the test. do_once: If we should only send one entry. This is used in the test.
Returns: Returns:
@ -48,11 +49,16 @@ def send_to_discord(custom_reader: Reader | None = None, do_once=False) -> None:
# Get the default reader if we didn't get a custom one. # Get the default reader if we didn't get a custom one.
reader: Reader = get_reader() if custom_reader is None else custom_reader reader: Reader = get_reader() if custom_reader is None else custom_reader
# Update the feeds. # Check for new entries for every feed.
reader.update_feeds() reader.update_feeds()
# If feed is not None we will only get the entries for that feed.
if feed is None:
# Get all the entries, we will loop through them and check if they should be sent. # Get all the entries, we will loop through them and check if they should be sent.
entries: Iterable[Entry] = reader.get_entries(read=False) entries: Iterable[Entry] = reader.get_entries(read=False)
else:
# Get all the entries, we will loop through them and check if they should be sent.
entries: Iterable[Entry] = reader.get_entries(feed=feed, read=False)
for entry in entries: for entry in entries:
# Set the webhook to read, so we don't send it again. # Set the webhook to read, so we don't send it again.