From eb6c1668bc8ca20c86e0793cfa745068d49f3dea Mon Sep 17 00:00:00 2001 From: Tunix2 Date: Fri, 16 Dec 2016 21:39:53 +0000 Subject: [PATCH] Beter formatting, peer dependency on latest dbcore --- aseen.js => lib/aseen.js | 7 ++++--- package.json | 6 +++++- plugin.js | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 14 deletions(-) rename aseen.js => lib/aseen.js (68%) diff --git a/aseen.js b/lib/aseen.js similarity index 68% rename from aseen.js rename to lib/aseen.js index cb68c12..e4db5d2 100644 --- a/aseen.js +++ b/lib/aseen.js @@ -18,12 +18,13 @@ function find(targetNick, targetChannel) { var now = moment(new Date()); var timeAgoMessage = moment(row.Timestamp).from(now); if (row.MessageType === 'privmsg') { - return format('Last activity to %s, content was "%s" %s', targetChannel, row.Message, timeAgoMessage); + return format('Last activity in %s %s: "%s".', targetChannel, timeAgoMessage, row.Message); } if (!row.Message) { - return format('Last activity to %s was a "%s" %s', targetChannel, row.MessageType, timeAgoMessage); + return format('Last activity in %s was a %s %s.', targetChannel, row.MessageType, timeAgoMessage); } - return format('Last activity to %s was a "%s", the content was "%s" %s', targetChannel, row.MessageType, row.Message, timeAgoMessage); + + return format('Last activity in %s was a %s %s: "%s".', targetChannel, row.MessageType, timeAgoMessage, row.Message); } else { return ('I have never seen any client activity from ' + targetNick + ' in ' + targetChannel); diff --git a/package.json b/package.json index bdbbeef..d584e6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tennu-aseen", - "version": "1.0.4", + "version": "2.0.0", "description": "A plugin for the tennu IRC framework, uses logging db to find last seen users.", "main": "plugin.js", "repository": { @@ -16,5 +16,9 @@ "dependencies": { "bluebird": "^3.0.5", "moment": "^2.10.6" + }, + "peerDependencies": { + "tennu-dbcore": "^2", + "tennu-dblogger": "^2" } } diff --git a/plugin.js b/plugin.js index 23c902f..3e6a773 100644 --- a/plugin.js +++ b/plugin.js @@ -1,7 +1,11 @@ +var path = require('path'); + var TennuAdvancedSay = { - requiresRoles: ['dbcore'], + requiresRoles: ['dblogger', 'dbcore'], init: function(client, imports) { + const knex = imports.dbcore.knex; + const helps = { "aseen": [ "{{!}}aseen " @@ -14,9 +18,7 @@ var TennuAdvancedSay = { }; // dbcore is a promise. It is returned after migrations are complete. - const dbASeenPromise = imports.dbcore.then(function(knex) { - return require('./aseen')(knex); - }); + var aseen = require('./lib/aseen')(knex); var lastSeen = (function() { return function(command) { @@ -29,11 +31,9 @@ var TennuAdvancedSay = { errorResponse.message = 'This command is not avalible as a PM.'; return errorResponse; } - return dbASeenPromise.then(function(aseen) { - return aseen.find(command.args[0], command.channel).then(function(result) { - return result; - }); - }) + return aseen.find(command.args[0], command.channel).then(function(result) { + return result; + }); } })(); @@ -52,4 +52,4 @@ var TennuAdvancedSay = { } }; -module.exports = TennuAdvancedSay; \ No newline at end of file +module.exports = TennuAdvancedSay;