本文整理汇总了Python中Core.Util.UtilBot.check_if_can_run_command方法的典型用法代码示例。如果您正苦于以下问题:Python UtilBot.check_if_can_run_command方法的具体用法?Python UtilBot.check_if_can_run_command怎么用?Python UtilBot.check_if_can_run_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core.Util.UtilBot
的用法示例。
在下文中一共展示了UtilBot.check_if_can_run_command方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: help
# 需要导入模块: from Core.Util import UtilBot [as 别名]
# 或者: from Core.Util.UtilBot import check_if_can_run_command [as 别名]
def help(bot, event, command=None, *args):
valid_user_commands = []
for command_test in sorted(DispatcherSingleton.commands.keys()):
if UtilBot.check_if_can_run_command(bot, event, command_test):
valid_user_commands.append(command_test)
docstring = """
**Current Implemented Commands:**
{}
Use: /<command name> ? or /help <command name> to find more information about the command.
""".format(', '.join(valid_user_commands))
if command == '?' or command is None:
bot.send_message_segments(event.conv, UtilBot.text_to_segments(docstring))
else:
if command in DispatcherSingleton.commands.keys():
func = DispatcherSingleton.commands[command]
if func.__doc__:
bot.send_message_segments(event.conv, UtilBot.text_to_segments(func.__doc__))
else: # Compatibility purposes for the old way of showing help text.
args = ['?']
func(bot, event, *args)
else:
bot.send_message("The command {} is not registered.".format(command))