Skip to content

Commit

Permalink
Merge pull request #1924 from sopel-irc/1619-renames
Browse files Browse the repository at this point in the history
plugin: rename plural decorators to be consistent
  • Loading branch information
dgw authored Aug 28, 2020
2 parents c7f30fa + 8ca958d commit 5525ed2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/source/plugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ However, sometimes multiple words are needed for clarity or disambiguation;

from sopel import plugin

@plugin.commands('hello')
@plugin.command('hello')
def say_hello(bot, trigger):
"""Reply hello to you."""
bot.reply('Hello!')
Expand Down
2 changes: 1 addition & 1 deletion sopel/config/core_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class CoreSection(StaticSection):
Liam
This would then allow both "William: Hi!" and "Bill: Hi!" to work with
:func:`~sopel.plugin.nickname_commands`.
:func:`~sopel.plugin.nickname_command`.
"""

auth_method = ChoiceAttribute('auth_method', choices=[
Expand Down
6 changes: 3 additions & 3 deletions sopel/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
# Therefore, don't add anything to this import list. Ever.
from sopel.plugin import ( # noqa
ADMIN,
action_commands,
commands,
action_command as action_commands,
command as commands,
echo,
event,
example,
HALFOP,
intent,
interval,
nickname_commands,
nickname_command as nickname_commands,
NOLIMIT,
OP,
OPER,
Expand Down
34 changes: 17 additions & 17 deletions sopel/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
# constants
'NOLIMIT', 'VOICE', 'HALFOP', 'OP', 'ADMIN', 'OWNER', 'OPER',
# decorators
'action_commands',
'commands',
'action_command',
'command',
'echo',
'event',
'example',
'find',
'intent',
'interval',
'label',
'nickname_commands',
'nickname_command',
'output_prefix',
'priority',
'rate',
Expand Down Expand Up @@ -358,7 +358,7 @@ def add_attribute(function):
return add_attribute


def commands(*command_list):
def command(*command_list):
"""Decorate a function to set one or more commands that should trigger it.
:param str command_list: one or more command name(s) to match
Expand All @@ -370,17 +370,17 @@ def commands(*command_list):
Example::
@commands("hello")
@command("hello")
# If the command prefix is "\\.", this would trigger on lines
# starting with ".hello".
@commands('j', 'join')
@command('j', 'join')
# If the command prefix is "\\.", this would trigger on lines
# starting with either ".j" or ".join".
You can use a space in the command name to implement subcommands::
@commands('main sub1', 'main sub2')
@command('main sub1', 'main sub2')
# For ".main sub1", trigger.group(1) will return "main sub1"
# For ".main sub2", trigger.group(1) will return "main sub2"
Expand All @@ -389,7 +389,7 @@ def commands(*command_list):
So for instance, to have ``.main`` and ``.main sub`` working properly, you
need to declare them like this::
@commands('main sub', 'main')
@command('main sub', 'main')
# This command will react properly to ".main sub" and ".main"
Then, you can check ``trigger.group(1)`` to know if it was used as
Expand All @@ -399,10 +399,10 @@ def commands(*command_list):
Another option is to declare command with subcommands only, like this::
@commands('main sub1)
@command('main sub1)
# this command will be triggered on .main sub1
@commands('main sub2')
@command('main sub2')
# this other command will be triggered on .main sub2
In that case, ``.main`` won't trigger anything, and you won't have to
Expand All @@ -414,11 +414,11 @@ def commands(*command_list):
are invoked in the reverse order of appearance::
# These two decorators...
@commands('hi')
@commands('hello')
@command('hi')
@command('hello')
# ...are equivalent to this single decorator
@commands('hello', 'hi')
@command('hello', 'hi')
See also the `Function Definitions`__ chapter from the Python
documentation for more information about functions and decorators.
Expand Down Expand Up @@ -450,7 +450,7 @@ def add_attribute(function):
return add_attribute


def nickname_commands(*command_list):
def nickname_command(*command_list):
"""Decorate a function to trigger on lines starting with "$nickname: command".
:param str command_list: one or more command name(s) to match
Expand All @@ -462,7 +462,7 @@ def nickname_commands(*command_list):
Example::
@nickname_commands("hello!")
@nickname_command("hello!")
# Would trigger on "$nickname: hello!", "$nickname, hello!",
# "$nickname hello!", "$nickname hello! parameter1" and
# "$nickname hello! p1 p2 p3 p4 p5 p6 p7 p8 p9".
Expand Down Expand Up @@ -495,7 +495,7 @@ def add_attribute(function):
return add_attribute


def action_commands(*command_list):
def action_command(*command_list):
"""Decorate a function to trigger on CTCP ACTION lines.
:param str command_list: one or more command name(s) to match
Expand All @@ -507,7 +507,7 @@ def action_commands(*command_list):
Example::
@action_commands("hello!")
@action_command("hello!")
# Would trigger on "/me hello!"
.. versionadded:: 7.0
Expand Down
4 changes: 2 additions & 2 deletions sopel/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ class Trigger(unicode):
.. seealso::
For more information on predefined numbered match groups in commands,
see :func:`.plugin.commands`, :func:`.plugin.action_commands`, and
:func:`.plugin.nickname_commands`.
see :func:`.plugin.command`, :func:`.plugin.action_command`, and
:func:`.plugin.nickname_command`.
Also see Python's :meth:`re.Match.group` documentation for details
about this method's behavior.
Expand Down

0 comments on commit 5525ed2

Please sign in to comment.