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 line limit to be set in config #3

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 5 additions & 0 deletions sopel_help/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ class HelpSection(config.types.StaticSection):
'origin_output_dir',
default='/var/www/html')
"""Where the file will be put on the server to publish the content."""

line_threshold = config.types.ValidatedAttribute(
'line_threshold',
default='3')
"""The maximum length (in lines) that the help for a specific command can be before it is sent in a private message."""
6 changes: 1 addition & 5 deletions sopel_help/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ class AbstractGeneratedProvider(AbstractProvider):
This abstract provider already implements the :meth:`send_help_command`
that sends the head/body/usage to the user.
"""
DEFAULT_THRESHOLD = 3

def get_threshold(self):
"""Get wrap width parameter."""
return self.DEFAULT_THRESHOLD

def generate_help_commands(self, command_groups):
"""Generate help messages for a set of commands.
Expand Down Expand Up @@ -135,7 +131,7 @@ def send_help_command(self, bot, trigger, command, head, body, usages):
"""
reply, recipient = self.get_reply_method(bot, trigger)
message_length = len([head] + body) + int(bool(usages))
if recipient != trigger.nick and message_length > self.get_threshold():
if recipient != trigger.nick and message_length > bot.config.line_threshold:
reply(
"The help for command %s is too long; "
"I'm sending it to you in a private message." % command)
Expand Down