rss-bot: Allow overriding the topic default.

rss-bot selects the topic of its RSS notification messages based on the
topic of the RSS feed. Monitoring a large number of RSS feeds therefore
leads to a large number of topics in the stream. Also, the user has no
option to customize the topic names.

This patch adds a new `--topic` argument that replaces the topic for
all RSS feed notifications with the provided string. If no custom topic
is provided, the bot uses the default behaviour described above.
This commit is contained in:
Daniel Teunis 2023-06-07 19:33:07 +02:00 committed by Tim Abbott
parent 5b2b0617a6
commit ae142a380d

View file

@ -58,6 +58,13 @@ parser.add_argument(
default="rss",
action="store",
)
parser.add_argument(
"--topic",
dest="topic",
help="A fixed topic to use for RSS messages, overriding the default of the feed title/URL",
default=None,
action="store",
)
parser.add_argument(
"--data-dir",
dest="data_dir",
@ -183,7 +190,7 @@ def send_zulip(entry: Any, feed_name: str) -> Dict[str, Any]:
message = {
"type": "stream",
"to": opts.stream,
"subject": elide_subject(feed_name),
"subject": opts.topic or elide_subject(feed_name),
"content": content,
} # type: Dict[str, str]
return client.send_message(message)