Skip to content

Commit

Permalink
Beter formatting, peer dependency on latest dbcore
Browse files Browse the repository at this point in the history
  • Loading branch information
LordZeroHour committed Dec 16, 2016
1 parent f786ce1 commit eb6c166
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
7 changes: 4 additions & 3 deletions aseen.js → lib/aseen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -16,5 +16,9 @@
"dependencies": {
"bluebird": "^3.0.5",
"moment": "^2.10.6"
},
"peerDependencies": {
"tennu-dbcore": "^2",
"tennu-dblogger": "^2"
}
}
20 changes: 10 additions & 10 deletions plugin.js
Original file line number Diff line number Diff line change
@@ -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 <nick>"
Expand All @@ -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) {
Expand All @@ -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;
});
}
})();

Expand All @@ -52,4 +52,4 @@ var TennuAdvancedSay = {
}
};

module.exports = TennuAdvancedSay;
module.exports = TennuAdvancedSay;

0 comments on commit eb6c166

Please sign in to comment.