diff --git a/modules/web.js b/modules/web.js index c1e25c1..f4dfd16 100644 --- a/modules/web.js +++ b/modules/web.js @@ -16,7 +16,12 @@ var webInterface = function(dbot) { }); app.listen(1337); - return { }; + + return { + 'onDestroy': function() { + process.exit(); + } + }; }; exports.fetch = function(dbot) { diff --git a/run.js b/run.js index 9e83d06..e35ed4f 100644 --- a/run.js +++ b/run.js @@ -17,6 +17,7 @@ var DBot = function(dModules, timers) { this.instance.join('#fail'); this.instance.join('#42'); this.instance.join('#itonlygetsworse'); + this.instance.join('#plur'); }.bind(this)); this.moduleNames = dModules; @@ -42,6 +43,12 @@ DBot.prototype.reloadModules = function() { require.cache[path] = undefined; require('./snippets'); + this.modules.each(function(module) { + if(module.onDestroy) { + module.onDestroy(); + } + }); + this.moduleNames.each(function(name) { var cacheKey = require.resolve('./modules/' + name); require.cache[cacheKey] = undefined; // TODO: snippet to remove element properly