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 = {
|
var commands = {
|
||||||
'~ncount': function(event) {
|
'~ncount': function(event) {
|
||||||
var chanCounts = {},
|
var chanCounts = {},
|
||||||
|
typeCounts = {},
|
||||||
total = 0,
|
total = 0,
|
||||||
offString = event.params[1] || null;
|
offString = event.params[1] || null;
|
||||||
offset = moment().subtract(offString, 1).valueOf() || null;
|
offset = moment().subtract(offString, 1).valueOf() || null;
|
||||||
|
|
||||||
console.log(offset);
|
|
||||||
|
|
||||||
/*if(!offset || !offset.isValid()) {
|
/*if(!offset || !offset.isValid()) {
|
||||||
event.reply('Invalid timescale. Try \'week\'');
|
event.reply('Invalid timescale. Try \'week\'');
|
||||||
return;
|
return;
|
||||||
@ -20,15 +19,16 @@ var commands = function(dbot) {
|
|||||||
if(notify.user == event.rUser.id) {
|
if(notify.user == event.rUser.id) {
|
||||||
if(!offString) {
|
if(!offString) {
|
||||||
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
||||||
|
if(!_.has(typeCounts, notify.type)) typeCounts[notify.type] = 0;
|
||||||
chanCounts[notify.channel]++;
|
chanCounts[notify.channel]++;
|
||||||
|
typeCounts[notify.type]++;
|
||||||
total++;
|
total++;
|
||||||
} else {
|
} else {
|
||||||
console.log(offset);
|
|
||||||
console.log(notify.time);
|
|
||||||
console.log();
|
|
||||||
if(notify.time > offset) {
|
if(notify.time > offset) {
|
||||||
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
||||||
|
if(!_.has(typeCounts, notify.type)) typeCounts[notify.type] = 0;
|
||||||
chanCounts[notify.channel]++;
|
chanCounts[notify.channel]++;
|
||||||
|
typeCounts[notify.type]++;
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,18 +47,33 @@ var commands = function(dbot) {
|
|||||||
}
|
}
|
||||||
cString = cString.slice(0, -2);
|
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) {
|
if(offString) {
|
||||||
event.reply(dbot.t('timed_notifies', {
|
event.reply(dbot.t('timed_notifies', {
|
||||||
'user': event.user,
|
'user': event.user,
|
||||||
'count': total,
|
'count': total,
|
||||||
'offString': offString,
|
'offString': offString,
|
||||||
'cString': cString
|
'cString': cString,
|
||||||
|
'tString': tString
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t('total_notifies', {
|
event.reply(dbot.t('total_notifies', {
|
||||||
'user': event.user,
|
'user': event.user,
|
||||||
'count': total,
|
'count': total,
|
||||||
'cString': cString
|
'cString': cString,
|
||||||
|
'tString': tString
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -83,9 +83,9 @@
|
|||||||
"de": "Du bist bereits für {cName} Benachrichtigungen angemeldet"
|
"de": "Du bist bereits für {cName} Benachrichtigungen angemeldet"
|
||||||
},
|
},
|
||||||
"total_notifies": {
|
"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": {
|
"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