Skip to content

Commit

Permalink
Merge pull request #42 from bbodenmiller/patch-2
Browse files Browse the repository at this point in the history
Add sub and unsub commands
  • Loading branch information
William B Ernest authored Feb 18, 2021
2 parents 2432ee4 + 716623f commit 3e08ee5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ To allow for the plugin to override user user name and icon on posts you must en
To use the plugin, navigate to the channel you want subscribed and use the following commands:
```
/feed help // to see the help menu
/feed subscribe <url> // to subscribe the channel to an rss feed
/feed unsubscribe <url> // to unsubscribe the channel from an rss feed
/feed subscribe <url> // to subscribe the channel to an RSS feed
/feed sub <url> // to subscribe the channel to an RSS feed
/feed unsubscribe <url> // to unsubscribe the channel from an RSS feed
/feed unsub <url> // to unsubscribe the channel from an RSS feed
/feed list // to list the feeds the channel is subscribed to
```

Expand Down
8 changes: 4 additions & 4 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "rssfeed",
"name": "RSSFeed",
"description": "This plugin serves as an rss subscription service for Mattermost.",
"description": "This plugin serves as an RSS subscription service for Mattermost.",
"version": "0.2.0",
"server": {
"executables": {
Expand All @@ -16,15 +16,15 @@
"settings": [
{
"key": "Heartbeat",
"display_name": "Time window between rss feed checks (minutes).",
"display_name": "Time window between RSS feed checks (minutes).",
"type": "text",
"help_text": "This is used to set a timer for the system to know when to go check to see if there is any new data in the subscribed rss feeds. Defaults to 15 minutes."
"help_text": "This is used to set a timer for the system to know when to go check to see if there is any new data in the subscribed RSS feeds. Defaults to 15 minutes."
},
{
"key": "ShowDescription",
"display_name": "Show Description in RSS post.",
"type": "bool",
"help_text": "(Optional) Use this field to hide the description in rss post (Useful if link already returns a valid link back to post)."
"help_text": "(Optional) Use this field to hide the description in RSS post (Useful if link already returns a valid link back to post)."
}

]
Expand Down
14 changes: 7 additions & 7 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
)

// COMMAND_HELP is the text you see when you type /feed help
const COMMAND_HELP = `* |/feed subscribe url| - Connect your Mattermost channel to an rss feed
* |/feed list| - Lists the rss feeds you have subscribed to
* |/feed unsubscribe url| - Unsubscribes the Mattermost channel from the rss feed`
const COMMAND_HELP = `* |/feed subscribe url| or |/feed sub url| - Connect your Mattermost channel to an RSS feed
* |/feed list| - Lists the RSS feeds you have subscribed to
* |/feed unsubscribe url| or |/feed unsub url| - Unsubscribes the Mattermost channel from the RSS feed`

// + `* |/feed initiate| - initiates the rss feed subscription poller`
// + `* |/feed initiate| - initiates the RSS feed subscription poller`

func getCommand() *model.Command {
return &model.Command{
Trigger: "feed",
DisplayName: "RSSFeed",
Description: "Allows user to subscribe to an rss feed.",
AutoComplete: true,
AutoCompleteDesc: "Available commands: list, subscribe, unsubscribe, help",
AutoCompleteDesc: "Available commands: list, subscribe, sub, unsubscribe, unsub, help",
AutoCompleteHint: "[command]",
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ func (p *RSSFeedPlugin) ExecuteCommand(c *plugin.Context, args *model.CommandArg
}
}
return getCommandResponse(model.COMMAND_RESPONSE_TYPE_EPHEMERAL, txt), nil
case "subscribe":
case "subscribe", "sub":

if len(parameters) == 0 {
return getCommandResponse(model.COMMAND_RESPONSE_TYPE_EPHEMERAL, "Please specify a url."), nil
Expand All @@ -84,7 +84,7 @@ func (p *RSSFeedPlugin) ExecuteCommand(c *plugin.Context, args *model.CommandArg
}

return getCommandResponse(model.COMMAND_RESPONSE_TYPE_EPHEMERAL, fmt.Sprintf("Successfully subscribed to %s.", url)), nil
case "unsubscribe":
case "unsubscribe", "unsub":
if len(parameters) == 0 {
return getCommandResponse(model.COMMAND_RESPONSE_TYPE_EPHEMERAL, "Please specify a url."), nil
} else if len(parameters) > 1 {
Expand Down

0 comments on commit 3e08ee5

Please sign in to comment.