def do_help(self, args): """Get help on commands 'help' or '?' with no arguments prints a list of commands for which help is available 'help <command>' or '? <command>' gives help on <command> """ ## The only reason to define this method is for the help text in the ## doc string #cmd.Cmd.do_help(self, args) commands.list_commands(self.conffile, args.split(' '))
def main(): print(commands.WELCOME) print() commands.list_commands() print() print('|file location defaulting to \'' + str(commands.file) + '\'...') print() while True: command(input('command> ')) print() return
def execute_selected_command(command_name, *args): commands = sorted(list_commands(), key=lambda x: x['index'] or 0) if command_name == 'all': for command in filter(lambda x: x['index'] is not None, commands): execute_command(command) return to_execute = find_command(command_name, commands) if to_execute is None: print('No such stript.') exit(1) return execute_command(to_execute)
async def on_message(message): if message.author != client.user: tmp = await check_triggers(message) if message.channel.is_private == False or message.content.startswith( config.get_prefix() + "help") or message.content.startswith( config.get_prefix() + "list") or message.content.startswith(config.get_prefix() + "commands"): sender = "<@" + message.author.id + ">" tells = commands.get_tells(sender) for tell in tells: tmp = await client.send_message(message.channel, tell) if (re.search("^" + config.get_prefix() + "\w+", message.content)): command = get_command(message.content) if command == "grab": async for log in client.logs_from(message.channel, limit=2): if not re.search(config.get_prefix() + "grab", log.content): commands.add_grab(log) tmp = await client.send_message( message.channel, "Grab Successful") elif command == "list" and config.check_command(command): tmp = await client.send_message(message.author, commands.list_places()) tmp2 = await client.send_message( message.channel, "I have PM'd you the list of places") elif command == "commands" and config.check_command(command): tmp = await client.send_message(message.author, commands.list_commands()) tmp2 = await client.send_message( message.channel, "I have PM'd you the list of commands") else: try: args = message.content.split(' ', 1)[1] except: args = "" if config.check_command(command): tmp = await client.send_message( message.channel, commands.get_response(message, command, args)) else: tmp = await client.send_message( message.channel, commands.get_unsupported_msg(command))
def list_all_commands(*args): commands = sorted(list_commands(), key=lambda x: x['index'] or 0) for command in commands: print('{} / {}'.format(command['unparsed_index'], command['name']))