3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 04:49:25 +01:00

derp derp

This commit is contained in:
reality 2013-10-16 15:22:45 +00:00
parent d7d8c34167
commit fc17201f35

View File

@ -3,21 +3,11 @@ var _ = require('underscore')._;
var commands = function(dbot) { var commands = function(dbot) {
var commands = { var commands = {
'~lines': function(event) { '~lines': function(event) {
if(event.params[1]) { var getLines = function(user) {
dbot.api.users.resolveUser(event.server, event.user, function(user) { this.api.getUserStats(user.id, function(uStats) {
if(user) { // I disgust me
event.rUser = user;
delete event['params'];
commands['~lines'](event);
} else {
event.reply(dbot.t('sstats_unknown_user'));
}
});
} else {
this.api.getUserStats(event.rUser.id, function(uStats) {
if(uStats) { if(uStats) {
var output = dbot.t('sstats_tlines', { var output = dbot.t('sstats_tlines', {
'user': event.rUser.primaryNick, 'user': user.primaryNick,
'lines': uStats.lines 'lines': uStats.lines
}); });
if(event.rChannel && _.has(uStats.channels, event.rChannel.id)) { if(event.rChannel && _.has(uStats.channels, event.rChannel.id)) {
@ -31,6 +21,18 @@ var commands = function(dbot) {
event.reply(dbot.t('sstats_noustats')); event.reply(dbot.t('sstats_noustats'));
} }
}); });
}.bind(this);
if(event.params[1]) {
dbot.api.users.resolveUser(event.server, event.params[1], function(user) {
if(user) {
getLines(user);
} else {
event.reply(dbot.t('sstats_unknown_user'));
}
});
} else {
getLines(event.rUser);
} }
}, },