'Reads in the bot configuration file and sets up the bot.
Defaults to config.txt if no configuration file is specified.
If you want to modify the bot configuration, edit your config.txt.'

def bot_setup(self, config_file='config.txt'):

    with open(config_file, 'r') as in_file:
        for line in in_file:
            line = line.split(':')
            parameter = line[0].strip()
            value = line[1].strip()
            if (parameter in ['USERS_KEEP_FOLLOWING', 'USERS_KEEP_UNMUTED', 'USERS_KEEP_MUTED']):
                if (value != ''):
                    self.BOT_CONFIG[parameter] = set([int(x) for x in value.split(',')])
                else:
                    self.BOT_CONFIG[parameter] = set()
            elif (parameter in ['FOLLOW_BACKOFF_MIN_SECONDS', 'FOLLOW_BACKOFF_MAX_SECONDS']):
                self.BOT_CONFIG[parameter] = int(value)
            else:
                self.BOT_CONFIG[parameter] = value
    required_parameters = ['OAUTH_TOKEN', 'OAUTH_SECRET', 'CONSUMER_KEY', 'CONSUMER_SECRET', 'TWITTER_HANDLE', 'ALREADY_FOLLOWED_FILE', 'FOLLOWERS_FILE', 'FOLLOWS_FILE']
    missing_parameters = []
    for required_parameter in required_parameters:
        if ((required_parameter not in self.BOT_CONFIG) or (self.BOT_CONFIG[required_parameter] == '')):
            missing_parameters.append(required_parameter)
    if (len(missing_parameters) > 0):
        self.BOT_CONFIG = {}
        raise Exception(('Please    edit    %s    to    include    the    following    parameters:    %s.\n\nThe    bot    cannot    run    unless    these    parameters    are    specified.' % (config_file, ',    '.join(missing_parameters))))
    for sync_file in [self.BOT_CONFIG['ALREADY_FOLLOWED_FILE'], self.BOT_CONFIG['FOLLOWS_FILE'], self.BOT_CONFIG['FOLLOWERS_FILE']]:
        if (not os.path.isfile(sync_file)):
            with open(sync_file, 'w') as out_file:
                out_file.write('')
    if (((time.time() - os.path.getmtime(self.BOT_CONFIG['FOLLOWS_FILE'])) > 86400) or ((time.time() - os.path.getmtime(self.BOT_CONFIG['FOLLOWERS_FILE'])) > 86400)):
        print('Warning:    Your    Twitter    follower    sync    files    are    more    than    a    day    old.    It    is    highly    recommended    that    you    sync    them    by    calling    sync_follows()    before    continuing.', file=sys.stderr)
    self.TWITTER_CONNECTION = Twitter(auth=OAuth(self.BOT_CONFIG['OAUTH_TOKEN'], self.BOT_CONFIG['OAUTH_SECRET'], self.BOT_CONFIG['CONSUMER_KEY'], self.BOT_CONFIG['CONSUMER_SECRET']))
