Skip to content

Commit

Permalink
enhance(core): add more way to customize help text (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsychov committed Nov 10, 2023
1 parent 3f0d36c commit 2933818
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config-example/bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ metrics: false
# true: enables prometheus metrics on localhost port 8080
# false: disable prometheus metrics

# Optional
# If you just want to customize default text of help, and keep help generation as is
# custom_help_text_prefix: "Hello from flotbot! I understand these commands:"

# Optional
# If you want to customize your help text
# custom_help_text: >
Expand Down
4 changes: 4 additions & 0 deletions core/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ func handleNoMatch(outputMsgs chan<- models.Message, message models.Message, hit
// If custom_help_text is not set, use default Help Text, for each rule use help_text from rule file
if helpMsg == "" {
helpMsg = "I understand these commands: \n"
if bot.CustomHelpTextPrefix != "" {
helpMsg = bot.CustomHelpTextPrefix + "\n"
}

// Go through all the rules and collect the help_text
for _, rule := range rules {
// Is the rule active and does the user want to expose the help for it? 'hear' rules don't show in help by default
Expand Down
1 change: 1 addition & 0 deletions models/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Bot struct {
Debug bool `mapstructure:"debug,omitempty"`
Metrics bool `mapstructure:"metrics,omitempty"`
CustomHelpText string `mapstructure:"custom_help_text,omitempty"`
CustomHelpTextPrefix string `mapstructure:"custom_help_text_prefix,omitempty"`
DisableNoMatchHelp bool `mapstructure:"disable_no_match_help,omitempty"`
RespondToBots bool `mapstructure:"respond_to_bots,omitempty"`
// System
Expand Down

0 comments on commit 2933818

Please sign in to comment.