def member(self, ctx):
"""Member settings"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
python类group()的实例源码
def keeper(self, ctx):
"""bookkeeper settings"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
def repo(self, ctx):
"""Repo management commands"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def profileset(self, ctx):
"""Profile options"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def rankset(self, ctx):
"""Rank options"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def levelupset(self, ctx):
"""Level-Up options"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def lvladminbg(self, ctx):
"""Admin Background Configuration"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def welcomeset_msg(self, ctx):
"""Manage welcome messages
"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def welcomeset_bot(self, ctx):
"""Special welcome for bots"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def replset_print(self, ctx):
"""Sets where repl content goes when response is too large."""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
def team_list(self, ctx):
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
def welcomeset_msg(self, ctx):
"""Manage welcome messages
"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def welcomeset_bot(self, ctx):
"""Special welcome for bots"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def repo(self, ctx):
"""Repo management commands"""
if ctx.invoked_subcommand is None or \
isinstance(ctx.invoked_subcommand, commands.Group):
await send_cmd_help(ctx)
return
def _set(self, ctx):
"""Configure build command"""
if ctx.invoked_subcommand is None or isinstance(ctx.invoked_subcommand, commands.Group):
await self.bot.say("Type help build set for info.")
def format(self):
"""
Formats the help page.
"""
# Adapted from discord.ext.commands.formatter.HelpFormatter.format
self._paginator = AryasPaginator()
description = self.command.description if not self.is_cog() else inspect.getdoc(self.command)
if description:
self._paginator.new_page(description=description)
if isinstance(self.command, Command):
# long help doc
if self.command.help:
self._paginator.add_line(self.command.help)
self._paginator.set_name(self.get_command_signature())
self._paginator.make_field(inline=False)
# if it's just a single command we're done here
if not self.has_subcommands():
return self._paginator.pages
# Helper method for sorting by category (cog)
def category(tup):
cog = tup[1].cog_name
# Unicode invisible space is there to set No Category last
return cog + ':' if cog is not None else '\u200bNo Category:'
# if command is a bot we need to process the entire command list
if self.is_bot():
data = sorted(self.filter_command_list(), key=category)
for category, commands in itertools.groupby(data, key=category):
commands = list(commands)
if len(commands) > 0:
self._add_entries(commands)
self._paginator.set_name(category)
self._paginator.make_field(inline=False)
else:
# if command is just a cog or Group we can print all the commands
# returned by filter_command_list
self._add_entries(self.filter_command_list())
self._paginator.set_name('Commands:')
self._paginator.make_field(inline=False)
# Get the ending message
self._paginator.set_name('More:')
self._paginator.add_line(self.get_ending_note())
self._paginator.make_field(inline=False)
return self._paginator.pages
def _make_commands(self):
group = commands.Group(
name=self.service_name,
callback=self._group_command,
help=self._make_help_string(strings.group_command_help),
)
group.instance = self
cmd = commands.Command(
name='add',
aliases=['subscribe'],
callback=self._add_command,
help=self._make_help_string(strings.add_command_help),
)
cmd.instance = self
group.add_command(cmd)
cmd = commands.Command(
name='del',
aliases=['unsubscribe', 'remove', 'delete'],
callback=self._del_command,
help=self._make_help_string(strings.del_command_help),
)
cmd.instance = self
group.add_command(cmd)
cmd = commands.Command(
name='list',
callback=self._list_command,
help=self._make_help_string(strings.list_command_help),
)
cmd.instance = self
group.add_command(cmd)
cmd = commands.Command(
name='enable',
callback=self._enable_command,
help=self._make_help_string(strings.enable_command_help),
)
cmd.instance = self
group.add_command(cmd)
cmd = commands.Command(
name='disable',
callback=self._disable_command,
help=self._make_help_string(strings.disable_command_help),
)
cmd.instance = self
group.add_command(cmd)
return group