slack-roll-command/index.js

25 lines
541 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);
}
2014-08-09 21:44:26 +00:00
module.exports = function(configuration) {
return function(ee) {
ee.on('roll', function(slack) {
try {
slack.replyUser(roll(slack.text));
} catch (e) {
slack.error(e.toString());
}
});
};
}