3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-25 04:02:39 +01:00
dbot/modules/js
2012-12-30 18:00:50 +00:00
..
js.js Moved all data loaded from config to be used only from dbot.config. Changed admin key in to admins to avoid clash with admin module config. Admins should probably be a key under dbot.admin module anyway. 2012-12-17 17:18:31 +00:00
README.md Documentation for the JS module [#75] 2012-12-30 18:00:50 +00:00
usage.json fix js/usage which I already fixed for some reason 2012-12-11 20:08:19 +00:00

JS

Run JavaScript.

Description

This module provides two commands which allow the execution of Javascript code from the bot.

Commands

~js [code]

For regular users, there is the ~js command, which is completely sandboxed, but can still be used for calculation and the like.

> ~js Array(16).join('wat'-1) + " Batman!";
'NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batman!'

This feature is fairly safe as the user doesnt have access to anything dangerous, and is safe from infinite loops or locking DBot up because the code which is run is killed if it does not finish within a short amount of time.

~ajs [code]

For administrators, the incredibly useful ~ajs command is also available. The input for this command is simply eval-ed and therefore has full access to DBots memory. Of course, this is incredibly unsafe, but I find it rather fun; remember to only give extremely trusted friends administrator access to your DBot instance, as theres nothing to stop them wiping the database or probably even your hard drive - if youre worried about that kind of thing, do not load this module.

However, its useful for many things, such as administrative activity for which there isnt a command in the admin module. For example, you could hot-add a new administrator like this:

> ~ajs dbot.admin.push('batman');
2

You can also use it for debugging, or even adding new commands while DBot is running.