Skip to content

Commit 08da3b6

Browse files
authored
Add optional argument to "feed" command for specifying template (#1097)
* Allow specifying a template as an optional argument to the "feed" command Signed-off-by: Molly Miller <[email protected]> * Document template argument in the "feed" command. Signed-off-by: Molly Miller <[email protected]> --------- Signed-off-by: Molly Miller <[email protected]> Co-authored-by: Molly Miller <[email protected]>
1 parent b0b61a7 commit 08da3b6

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

changelog.d/1097.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add an optional template argument to the `feed` command, to allow specifying a template for feed entries when using the command interface.

docs/setup/feeds.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ may include any of the following tokens:
6060
| $SUMMARY | The summary of the entry. |
6161

6262
If not specified, the default template is `New post in $FEEDNAME: $LINK`.
63+
64+
The template can also be given as an argument when adding the feed to a room, e.g. `!hookshot feed <URL> <LABEL> <TEMPLATE>`. If the template contains spaces, it can be quoted using double quotes.

src/Connections/SetupConnection.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,16 @@ export class SetupConnection extends CommandConnection {
624624
@botCommand("feed", {
625625
help: "Bridge an RSS/Atom feed to the room.",
626626
requiredArgs: ["url"],
627-
optionalArgs: ["label"],
627+
optionalArgs: ["label", "template"],
628628
includeUserId: true,
629629
category: FeedConnection.ServiceCategory,
630630
})
631-
public async onFeed(userId: string, url: string, label?: string) {
631+
public async onFeed(
632+
userId: string,
633+
url: string,
634+
label?: string,
635+
template?: string,
636+
) {
632637
if (!this.config.feeds?.enabled) {
633638
throw new CommandError(
634639
"not-configured",
@@ -660,7 +665,7 @@ export class SetupConnection extends CommandConnection {
660665
const { connection } = await FeedConnection.provisionConnection(
661666
this.roomId,
662667
userId,
663-
{ url, label },
668+
{ url, label, template },
664669
this.provisionOpts,
665670
);
666671
this.pushConnections(connection);

0 commit comments

Comments
 (0)