diff --git a/modules/sstats/commands.js b/modules/sstats/commands.js index 40c9d60..e3ca433 100644 --- a/modules/sstats/commands.js +++ b/modules/sstats/commands.js @@ -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; diff --git a/modules/sstats/sstats.js b/modules/sstats/sstats.js index 1421801..26df7fb 100644 --- a/modules/sstats/sstats.js +++ b/modules/sstats/sstats.js @@ -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;