Skip to content

Commit

Permalink
Update help command and description for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Civil committed Apr 14, 2019
1 parent fb38ea0 commit 89ce0e7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
17 changes: 17 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Changes
=================================================

[Fix] - bugfix

**[Breaking]** - breaking change

[Feature] - new feature

[Improvement] - non-breaking improvement

[Code] - code quality related change that shouldn't make any significant difference for end-user

CHANGELOG
---------
**0.0.1**
- [Improvement] Initial release
27 changes: 20 additions & 7 deletions endpoints/telegram_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,28 @@ func InitializeTelegramEndpoint(token string, exitChan <-chan struct{}, database
e.commands = map[string]handlerWithDescription{
"/new": {
f: e.handlerNew,
description: "`/new repo filter_name filter_regexp` -- creates new available subscription",
description: "`/new repo filter_name filter_regexp` -- creates new available subscription" + `
Example:
` + "`/new lomik/go-carbon all ^V`" + `
This will create repo named 'lomik/go-carbon', with filter called 'all' and regexp that will grab all tags that starts from capital 'V'`,
},
"/subscribe": {
f: e.handlerSubscribe,
description: "`/subscribe repo filter_name` -- subscribe current channel to specific repo and filter",
description: "`/subscribe repo filter_name` -- subscribe current channel to specific repo and filter" + `
Example:
` + "`/subscribe lomik/go-carbon all`" + `
`,
},
"/unsubscribe": {
f: e.handlerUnsubscribe,
description: "`/unsubscribe repo filter_name` -- unsubscribe current channel to specific repo and filter",
description: "`/unsubscribe repo filter_name` -- unsubscribe current channel to specific repo and filter" + `
Example:
` + "`/unsubscribe lomik/go-carbon all`" + `
`,
},
"/list": {
f: e.handlerList,
Expand Down Expand Up @@ -156,7 +169,7 @@ func (e *TelegramEndpoint) handlerNew(tokens []string, update *tgbotapi.Update)
return errUnauthorized
}
if len(tokens) < 4 {
return errors.New("Not enough arguments\n\nUsage: /new repo_name filter_name filter_regex [message_pattern (will replace first '%s' with feed name]")
return errors.New("Command require exactly 4 arguments\n\n" + e.commands["/new"].description)
}

repo := tokens[1]
Expand Down Expand Up @@ -208,7 +221,7 @@ func (e *TelegramEndpoint) handlerSubscribe(tokens []string, update *tgbotapi.Up
}

if len(tokens) != 3 {
return errors.New("/subscribe requires exactly 2 arguments")
return errors.New("/subscribe requires exactly 2 arguments.\n\n" + e.commands["/subscribe"].description)
}

url := tokens[1]
Expand Down Expand Up @@ -248,7 +261,7 @@ func (e *TelegramEndpoint) handlerUnsubscribe(tokens []string, update *tgbotapi.
}

if len(tokens) != 3 {
return errors.New("/unsubscribe requires exactly 3 arguments")
return errors.New("/unsubscribe requires exactly 2 arguments\n\n" + e.commands["/unsubscribe"].description)
}

url := tokens[1]
Expand Down Expand Up @@ -295,7 +308,7 @@ func (e *TelegramEndpoint) handlerList(tokens []string, update *tgbotapi.Update)
func (e *TelegramEndpoint) handlerHelp(tokens []string, update *tgbotapi.Update) error {
response := ""
for _, v := range e.commands {
response = response + v.description + "\n"
response = response + v.description + "\n\n==============================\n\n"
}

e.sendMessage(update.Message.Chat.ID, update.Message.MessageID, response)
Expand Down

0 comments on commit 89ce0e7

Please sign in to comment.