3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

~last thing

This commit is contained in:
reality 2013-10-17 14:31:05 +00:00
parent 44316a5de1
commit 54a0a96cbc
2 changed files with 19 additions and 1 deletions

View File

@ -1,5 +1,6 @@
var _ = require('underscore')._,
async = require('async');
async = require('async'),
moment = require('moment');
var commands = function(dbot) {
var commands = {
@ -154,6 +155,22 @@ var commands = function(dbot) {
'channel': event.channel,
'lines': event.cStats.lines
}));
},
'~last': function(event) {
dbot.api.users.resolveUser(event.server, event.params[1], function(user) {
if(user) {
this.api.getUserStats(user.id, function(uStats) {
if(uStats && uStats.last) {
event.reply(user.primaryNick + ' was last seen ' + moment(uStats.last).fromNow() + '.');
} else {
event.reply('I haven\'t seen that user active yet.');
}
});
} else {
event.reply('Unknown user.');
}
}.bind(this));
}
};
return commands;

View File

@ -91,6 +91,7 @@ var sstats = function(dbot) {
event.uStats.words += wCount;
event.uStats.capitals += capitals;
event.uStats.curses += curses;
event.uStats.last = new Date().getTime();
event.cStats.words += wCount;
event.cStats.capitals += capitals;