forked from GitHub/dbot
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
var _ = require('underscore')._;
|
|
|
|
var commands = function(dbot) {
|
|
var commands = {
|
|
'~lines': function(event) {
|
|
var getLines = function(user) {
|
|
this.api.getUserStats(user.id, function(uStats) {
|
|
if(uStats) {
|
|
var output = dbot.t('sstats_tlines', {
|
|
'user': user.primaryNick,
|
|
'lines': uStats.lines
|
|
});
|
|
if(event.rChannel && _.has(uStats.channels, event.rChannel.id)) {
|
|
output += dbot.t('sstats_uclines', {
|
|
'channel': event.channel,
|
|
'lines': uStats.channels[event.rChannel.id].lines
|
|
});
|
|
}
|
|
event.reply(output);
|
|
} else {
|
|
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);
|
|
}
|
|
},
|
|
|
|
'~clines': function(event) {
|
|
if(!event.cStats) return;
|
|
event.reply(dbot.t('sstats_clines', {
|
|
'channel': event.channel,
|
|
'lines': event.cStats.lines
|
|
}));
|
|
}
|
|
};
|
|
return commands;
|
|
};
|
|
|
|
exports.fetch = function(dbot) {
|
|
return commands(dbot);
|
|
};
|