UNPKG

domo-eval

Version:

Eval plugin for Domo-bot

1 lines 982 B
var Sandbox,coffee,getCode;Sandbox=require("sandbox"),coffee=require("coffee-script"),getCode=function(o,e){return o.code=o.splats[0],e()},module.exports.init=function(o){return o.route("!eval",function(o){return this.say(o.channel,"Domo-eval - Javascript evaluator for Domo\nusage: !eval <flags> <JavaScript|CoffeeScript>\nFlags:\n -c [-v] Evaluate coffeescript, verbose compiled JavaScript with -v flag")}),o.route("!eval -c -v *",getCode,function(o){var e;try{o.code=coffee.compile(o.code,{bare:!0}).replace("\n","")}catch(n){return e=n,this.say(o.channel,e.message)}return this.say(o.channel,o.code)}),o.route("!eval -c *",getCode,function(o){var e,n=this;try{o.code=coffee.compile(o.code,{bare:!0}).replace("\n","")}catch(t){return e=t,this.say(o.channel,e.message)}return(new Sandbox).run(o.code,function(e){return n.say(o.channel,e.result)})}),o.route("!eval *",getCode,function(o){var e=this;return(new Sandbox).run(o.code,function(n){return e.say(o.channel,n.result)})})};