mirror of
https://github.com/reality/dbot.git
synced 2024-12-28 05:32:50 +01:00
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).
|
||||
'~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]);
|
||||
if(ret !== undefined) {
|
||||
event.reply(ret);
|
||||
|
Loading…
Reference in New Issue
Block a user