diff --git a/discord_rss_bot/main.py b/discord_rss_bot/main.py index 133fce7..b026a07 100644 --- a/discord_rss_bot/main.py +++ b/discord_rss_bot/main.py @@ -1,3 +1,5 @@ +from typing import Optional + import typer from dhooks import Webhook from reader import FeedExistsError, make_reader @@ -10,7 +12,10 @@ reader = make_reader(Settings.db_file) # For RSS (https://github.com/lemon24/re @app.command() -def add(feed_url: str) -> None: +def add( + feed_url: str = typer.Argument(..., help="RSS or Atom feed URL."), + notify_discord: bool = typer.Option(False, help="Send message to Discord."), +) -> None: """Add a feed to the database Args: @@ -32,6 +37,13 @@ def add(feed_url: str) -> None: for entry in entries: reader.mark_entry_as_read(entry) + if notify_discord: + # Send a message to Discord + hook.send( + f"discord-rss-bot: {feed_url} added to the database.\nYou now have " + f"{reader.get_feed_counts()} feeds." + ) + typer.echo(f"{feed_url} added")