def command(self): if not self.args: self.generic_help() return name = self.args[0] commands = get_commands() if name not in commands: print 'No such command: %s' % name self.generic_help() return command = commands[name].load() runner = command(name) runner.run(['-h'])
def command(self): if not self.args: self.generic_help() return name = self.args[0] commands = get_commands() if name not in commands: print 'No such command: %s' % name self.generic_help() return command = commands[name].load() runner = command(name) runner.run(['-h'])
def generic_help(self): base_parser.print_help() print commands_grouped = {} commands = get_commands() longest = max([len(n) for n in commands.keys()]) for name, command in commands.items(): try: command = command.load() except Exception, e: print 'Cannot load command %s: %s' % (name, e) continue if getattr(command, 'hidden', False): continue commands_grouped.setdefault( command.group_name, []).append((name, command))
def generic_help(self): base_parser.print_help() print commands_grouped = {} commands = get_commands() longest = max([len(n) for n in commands.keys()]) for name, command in commands.items(): try: command = command.load() except Exception, e: print 'Cannot load command %s: %s' % (name, e) continue if getattr(command, 'hidden', False): continue commands_grouped.setdefault(command.group_name, []).append( (name, command))
def __init__(self): # Get the Bot token from the environment. Raises RunTimeError if the # value isn't set because the bot can't run without a token configured. slack_bot_token = os.environ.get('SLACK_BOT_TOKEN') if slack_bot_token == '': raise RuntimeError('SLACK_BOT_TOKEN must be set in the environment.') # Create the main SlackClient instance for the bot self.slack_client = SlackClient(slack_bot_token) # start initial connection to Slack RTM if self.slack_client.rtm_connect(with_team_state=False): logger.info("AA5ROBot connected to Slack.") self.aa5robot_id = self.slack_client.api_call("auth.test")["user_id"] else: logger.warning("Connection to Slack RTM failed.") self.shutdown(1) # Load the bot's commands self.commands = command.get_commands() print('AA5RObot initialized.')