def load_fortunes_cb(bot, message=None, *args, **kwargs): ''' (Re)load all fortune and specials files from their directories. ''' LOGGER.info('Loading specials.') for root, dummy, files in os.walk('specials/'): for file_ in files: if not file_.endswith('.spc'): continue LOGGER.debug('Loading specials file %s', file_) abspath = os.path.join(root, file_) try: fortune.make_fortune_data_file(abspath, True) SPECIALS[file_] = abspath LOGGER.debug('Specials file %s loaded.', abspath) except (TypeError, ValueError) as ex: LOGGER.error('Specials file %s failed to load: %s', abspath, ex) LOGGER.info('%s specials loaded.', len(SPECIALS)) LOGGER.info('Loading fortunes.') for root, dummy, files in os.walk('fortunes/'): for file_ in files: if not file_.endswith('.txt'): continue LOGGER.debug('Loading fortune file %s', file_) abspath = os.path.join(root, file_) try: fortune.make_fortune_data_file(abspath, True) FORTUNE_FILES.append(abspath) LOGGER.debug('Fortune file %s loaded.', abspath) except ValueError as ex: LOGGER.error('Fortune file %s failed to load: %s', abspath, ex) LOGGER.info('%s fortune files loaded.', len(FORTUNE_FILES)) if message: return 'Done.'