From e62a1c848403c9007a62dde91da86586bdfd1f05 Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 2 Nov 2017 18:22:05 +0000 Subject: [PATCH] external lpmcount --- modules/cspeed/cspeed.js | 11 ++++++++--- modules/users/users.js | 4 +++- run.js | 8 +++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/modules/cspeed/cspeed.js b/modules/cspeed/cspeed.js index 2a6a020..ad6b9bd 100644 --- a/modules/cspeed/cspeed.js +++ b/modules/cspeed/cspeed.js @@ -1,13 +1,18 @@ var _ = require('underscore')._; var cspeed = function(dbot) { - if(!_.has(dbot.db.cspeed)) { - dbot.db.cspeed = {}; - } this.watches = dbot.db.cspeed; this.outputChannel = dbot.config.modules.cspeed.outputChannel; this.counts = {}; + this.api = { + 'getCounts': function(callback) { + callback(this.counts); + } + }; + this.api['getCounts'].external = true; + this.api['getCounts'].extMap = [ 'callback' ]; + this.commands = { 'addlpmwatch': function(event) { var channel = event.params[1]; diff --git a/modules/users/users.js b/modules/users/users.js index 9b924cf..55bfe37 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -108,7 +108,9 @@ var users = function(dbot) { // Track nick changes this.listener = function(event) { // Update current nick - console.log(event); + async.waterfall([ + + ]); this.api.resolveUser(event.server, event.user, function(err, user) { if(user) { this.api.resolveUser(event.server, event.message, function(err, eUser) { diff --git a/run.js b/run.js index 91d36ef..54c5e00 100644 --- a/run.js +++ b/run.js @@ -122,13 +122,15 @@ DBot.prototype.t = function(string, formatData) { }*/ // Save the database file -DBot.prototype.save = function() { - fs.writeFileSync('db.json', JSON.stringify(this.db, null, ' ')); +DBot.prototype.save = function(cb) { + fs.writeFile('db.json', JSON.stringify(this.db, null, ' '), cb); }; // Hot-reload module files. DBot.prototype.reloadModules = function() { - this.save(); + this.save().then(function() { + console.log('test'); + }); if(this.modules) { // Run 'onDestroy' code for each module if it exists. _.each(this.modules, function(module) {