Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a custom help message. #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/pagerbot/action_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def help(query, event_data)
render(
'help',
loaded_plugins: plugin_manager.loaded_plugins,
help_message: @options[:bot][:help_message],
name: @options[:bot][:name])
end

Expand Down
8 changes: 8 additions & 0 deletions public/views/bot.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ <h1 ng-show="bot.adapter == 'hipchat'">HipChat settings</h1>
</span>
</p>

<p class="paragraph">
<label class="control-label">Help message:</label>
<input ng-model="bot.help_message" class="form-control short" />
<span class="input-description">
An optional extra message to be included in the bot help output. Useful for site specific details.
</span>
</p>

<div class="paragraph" ng-if="bot.adapter != 'slack-rtm'">
<label class="control-label">Channels:</label>

Expand Down
4 changes: 3 additions & 1 deletion templates/help_irc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ I am <%= name %>, and I keep track of the pagers. You can ask me the following:
<%= syntax %>

<% end %>
<% end %>
<% end %>
<% if help_message.present? %>
<%= help_message %><% end %>
14 changes: 13 additions & 1 deletion test/unit/pagerbot/action_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ def event_data(opts={nick: "karl"})
assert_includes(help_text, 'list')
assert_includes(help_text, 'people')
end

it 'should include help link if provided' do
@bot_settings[:help_message] = "https://example.com/help"
@manager = PagerBot::ActionManager.new(
:pagerduty => @pagerduty_settings,
:bot => @bot_settings)
@pagerduty = @manager.instance_variable_get("@pagerduty")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty derpy but I couldn't figure out a better way to hook into the test life-cycle without a bigger refactoring... Suggestions?


help_text = @manager.dispatch({type: 'help'}, event_data)[:message]

assert_includes(help_text, 'https://example.com/help')
end
end

describe 'manual' do
Expand All @@ -152,4 +164,4 @@ def event_data(opts={nick: "karl"})
end
end
end
end
end