mirror of
https://github.com/reality/dbot.git
synced 2024-11-24 04:49:25 +01:00
types
This commit is contained in:
parent
e2190444a8
commit
54f4d4979c
@ -5,12 +5,11 @@ var commands = function(dbot) {
|
||||
var commands = {
|
||||
'~ncount': function(event) {
|
||||
var chanCounts = {},
|
||||
typeCounts = {},
|
||||
total = 0,
|
||||
offString = event.params[1] || null;
|
||||
offset = moment().subtract(offString, 1).valueOf() || null;
|
||||
|
||||
console.log(offset);
|
||||
|
||||
/*if(!offset || !offset.isValid()) {
|
||||
event.reply('Invalid timescale. Try \'week\'');
|
||||
return;
|
||||
@ -20,15 +19,16 @@ var commands = function(dbot) {
|
||||
if(notify.user == event.rUser.id) {
|
||||
if(!offString) {
|
||||
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
||||
if(!_.has(typeCounts, notify.type)) typeCounts[notify.type] = 0;
|
||||
chanCounts[notify.channel]++;
|
||||
typeCounts[notify.type]++;
|
||||
total++;
|
||||
} else {
|
||||
console.log(offset);
|
||||
console.log(notify.time);
|
||||
console.log();
|
||||
if(notify.time > offset) {
|
||||
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
||||
if(!_.has(typeCounts, notify.type)) typeCounts[notify.type] = 0;
|
||||
chanCounts[notify.channel]++;
|
||||
typeCounts[notify.type]++;
|
||||
total++;
|
||||
}
|
||||
}
|
||||
@ -47,18 +47,33 @@ var commands = function(dbot) {
|
||||
}
|
||||
cString = cString.slice(0, -2);
|
||||
|
||||
var tCounts = _.chain(typeCounts)
|
||||
.pairs()
|
||||
.sortBy(function(p) { return p[1]; })
|
||||
.reverse()
|
||||
.first(10)
|
||||
.value();
|
||||
|
||||
var cttring = '';
|
||||
for(var i=0;i<tCounts.length;i++) {
|
||||
tString += tCounts[i][0] + " (" + tCounts[i][1] + "), ";
|
||||
}
|
||||
tString = tString.slice(0, -2);
|
||||
|
||||
if(offString) {
|
||||
event.reply(dbot.t('timed_notifies', {
|
||||
'user': event.user,
|
||||
'count': total,
|
||||
'offString': offString,
|
||||
'cString': cString
|
||||
'cString': cString,
|
||||
'tString': tString
|
||||
}));
|
||||
} else {
|
||||
event.reply(dbot.t('total_notifies', {
|
||||
'user': event.user,
|
||||
'count': total,
|
||||
'cString': cString
|
||||
'cString': cString,
|
||||
'tString': tString
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -83,9 +83,9 @@
|
||||
"de": "Du bist bereits für {cName} Benachrichtigungen angemeldet"
|
||||
},
|
||||
"total_notifies": {
|
||||
"en": "{user} has a total of {count} notifies. Channels: {cString}"
|
||||
"en": "{user} has a total of {count} notifies. Channels: {cString}. Types: {tString}."
|
||||
},
|
||||
"timed_notifies": {
|
||||
"en": "{user} has made {count} notifies in the last {offString}. Channels: {cString}"
|
||||
"en": "{user} has made {count} notifies in the last {offString}. Channels: {cString}. Types: {tString}"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user