3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 12:29:26 +01:00
This commit is contained in:
reality 2013-08-29 21:12:45 +00:00
parent 26bce2e8a0
commit 6d1d5d0afe
5 changed files with 48 additions and 11 deletions

View File

@ -10,10 +10,7 @@
"bio": null,
"favourites": {
"colour": null
}
},
"preferences": {
"timezone": null
},
}
},
"dependencies": [ "web", "quotes", "users" ]

View File

@ -1,5 +1,6 @@
var _ = require('underscore')._,
async = require('async');
async = require('async'),
moment = require('moment-timezone');
var pages = function(dbot) {
var pages = {
@ -55,9 +56,16 @@ var pages = function(dbot) {
user = req.user,
notifies = this.pending[user.id];
notifies = _.sortBy(notifies, 'time').reverse();
if(req.user.timezone) {
_.each(notifies, function(v, k) {
v.time = moment(v.time).tz(req.user.timezone);
});
}
res.render('missing_notifies', {
'user': user.primaryNick,
'notifies': _.sortBy(notifies, 'time')
'notifies': notifies
});
if(_.has(dbot.modules, 'log')) {
@ -92,9 +100,16 @@ var pages = function(dbot) {
next();
}
}, function() {
notifies = _.sortBy(notifies, 'time').reverse();
if(req.user.timezone) {
_.each(notifies, function(v, k) {
v.time = moment(v.time).tz(req.user.timezone);
});
}
res.render('notifies', {
'server': server,
'notifies': _.sortBy(notifies, 'time').reverse()
'notifies': notifies
});
});
});
@ -108,9 +123,16 @@ var pages = function(dbot) {
notify.user = user.primaryNick;
notifies.push(notify);
}, function() {
notifies = _.sortBy(notifies, 'time').reverse();
if(req.user.timezone) {
_.each(notifies, function(v, k) {
v.time = moment(v.time).tz(req.user.timezone);
});
}
res.render('notifies', {
'server': server,
'notifies': _.sortBy(notifies, 'time').reverse()
'notifies': notifies
});
});
}.bind(this));

View File

@ -1,4 +1,5 @@
var _ = require('underscore')._;
var _ = require('underscore')._,
moment = require('moment-timezone');
var commands = function(dbot) {
var commands = {
@ -34,6 +35,23 @@ var commands = function(dbot) {
}
});
},
'~timezone': function(event) {
if(event.params[1]) {
try {
moment().tz(event.params[1]);
} catch(err) {
return event.reply('Invalid timezone. See http://momentjs.com/timezone/');
}
event.rUser.timezone = event.params[1];
this.db.save('users', event.rUser.id, event.rUser, function() {
event.reply('Timezone updated.');
});
} else {
event.reply('Current timezone: ' + event.rUser.timezone);
}
},
'~setmobilealias': function(event) {
if(_.include(event.rUser.aliases, event.params[1])) {

View File

@ -15,5 +15,5 @@ block content
tbody
each notify in notifies
tr
td #{new Date(notify.time)}
td #{notify.time}
td #{notify.message}

View File

@ -18,7 +18,7 @@ block content
tbody
for notify in notifies
tr
td #{new Date(notify.time)}
td #{notify.time}
td #{notify.channel}
td #{notify.type}
td #{notify.user}