Skip to content

Instantly share code, notes, and snippets.

@silentrob
Created January 24, 2015 23:37
Show Gist options
  • Save silentrob/61d3c0596afe89afb8b4 to your computer and use it in GitHub Desktop.
Save silentrob/61d3c0596afe89afb8b4 to your computer and use it in GitHub Desktop.
Creating a boot file for a superscript bot
var facts = require("sfacts");
var fs = require("fs");
var worldData = [
'./data/concepts.top',
'./data/names.top',
'./data/oppisite.tbl',
'./data/worlddata/animals.tbl',
'./data/worlddata/color.tbl'
];
facts.load(worldData, "britfacts", function(err, res){
var parse = require("superscript/lib/parse")(res);
var exists = fs.existsSync('./data.json');
var contents = {};
var sums = {};
if (exists) {
contents = fs.readFileSync('./data.json', 'utf-8');
contents = JSON.parse(contents);
sums = contents.checksums;
}
parse.loadDirectory('./topics', sums, function(err, result) {
parse.merge(contents, result, function(err, results) {
fs.writeFile('./data.json', JSON.stringify(results), function (err) {
console.log("Loaded");
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment