forked from GitHub/dbot
Automatic callback for ~ajs [#476]
This commit is contained in:
parent
e7605e0c0e
commit
7e4ae2460a
@ -21,6 +21,16 @@ var js = function(dbot) {
|
|||||||
|
|
||||||
// Run JS code un-sandboxed, with access to DBot memory (admin-only).
|
// Run JS code un-sandboxed, with access to DBot memory (admin-only).
|
||||||
'~ajs': function(event) {
|
'~ajs': function(event) {
|
||||||
|
var callback = function() {
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
for(var i=0;i<args.length;i++) {
|
||||||
|
var arg = args[i];
|
||||||
|
if(_.isObject(arg) && !_.isArray(arg)) {
|
||||||
|
arg = '[object Object]: ' + _.keys(arg).join(', ');
|
||||||
|
}
|
||||||
|
event.reply('Callback[' + i + ']: ' + arg);
|
||||||
|
}
|
||||||
|
};
|
||||||
var ret = eval(event.input[1]);
|
var ret = eval(event.input[1]);
|
||||||
if(ret !== undefined) {
|
if(ret !== undefined) {
|
||||||
event.reply(ret);
|
event.reply(ret);
|
||||||
|
Loading…
Reference in New Issue
Block a user