slack-roll-command/index.js

24 lines
471 B
JavaScript
Raw Permalink Normal View History

2014-08-09 04:01:16 +00:00
var PEG = require('pegjs'),
path = require('path'),
fs = require('fs');
var parser = PEG.buildParser(
fs.readFileSync(
path.resolve(__dirname, "roll.pegjs")
).toString()
);
function roll(text) {
return "" + parser.parse(text);
}
module.exports = function(ee) {
ee.on('roll', function(slack) {
try {
slack.replyUser(roll(slack.text));
} catch (e) {
slack.error(e.toString());
}
});
};