本文整理匯總了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))