mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 11:42:36 +01:00
time thing
This commit is contained in:
parent
131233e7d0
commit
6990a10d9c
@ -1,16 +1,37 @@
|
|||||||
var _ = require('underscore')._;
|
var _ = require('underscore')._,
|
||||||
|
moment = require('moment');
|
||||||
|
|
||||||
var commands = function(dbot) {
|
var commands = function(dbot) {
|
||||||
var commands = {
|
var commands = {
|
||||||
'~ncount': function(event) {
|
'~ncount': function(event) {
|
||||||
var chanCounts = {},
|
var chanCounts = {},
|
||||||
total = 0;
|
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;
|
||||||
|
}*/
|
||||||
|
|
||||||
this.db.scan('notifies', function(notify) {
|
this.db.scan('notifies', function(notify) {
|
||||||
if(notify.user == event.rUser.id) {
|
if(notify.user == event.rUser.id) {
|
||||||
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
if(!offString) {
|
||||||
chanCounts[notify.channel]++;
|
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
||||||
total++;
|
chanCounts[notify.channel]++;
|
||||||
|
total++;
|
||||||
|
} else {
|
||||||
|
console.log(offset);
|
||||||
|
console.log(notify.time);
|
||||||
|
console.log();
|
||||||
|
if(notify.time > offset) {
|
||||||
|
if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0;
|
||||||
|
chanCounts[notify.channel]++;
|
||||||
|
total++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, function() {
|
}, function() {
|
||||||
var cCounts = _.chain(chanCounts)
|
var cCounts = _.chain(chanCounts)
|
||||||
@ -26,11 +47,20 @@ var commands = function(dbot) {
|
|||||||
}
|
}
|
||||||
cString = cString.slice(0, -2);
|
cString = cString.slice(0, -2);
|
||||||
|
|
||||||
event.reply(dbot.t('total_notifies', {
|
if(offString) {
|
||||||
'user': event.user,
|
event.reply(dbot.t('timed_notifies', {
|
||||||
'count': total,
|
'user': event.user,
|
||||||
'cString': cString
|
'count': total,
|
||||||
}));
|
'offString': offString,
|
||||||
|
'cString': cString
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('total_notifies', {
|
||||||
|
'user': event.user,
|
||||||
|
'count': total,
|
||||||
|
'cString': cString
|
||||||
|
}));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -84,5 +84,8 @@
|
|||||||
},
|
},
|
||||||
"total_notifies": {
|
"total_notifies": {
|
||||||
"en": "{user} has a total of {count} notifies. Channels: {cString}"
|
"en": "{user} has a total of {count} notifies. Channels: {cString}"
|
||||||
|
},
|
||||||
|
"timed_notifies": {
|
||||||
|
"en": "{user} has made {count} notifies in the last {offString}. Channels: {cString}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user