3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +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, "bio": null,
"favourites": { "favourites": {
"colour": null "colour": null
} },
},
"preferences": {
"timezone": null
} }
}, },
"dependencies": [ "web", "quotes", "users" ] "dependencies": [ "web", "quotes", "users" ]

View File

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

View File

@ -1,4 +1,5 @@
var _ = require('underscore')._; var _ = require('underscore')._,
moment = require('moment-timezone');
var commands = function(dbot) { var commands = function(dbot) {
var commands = { var commands = {
@ -35,6 +36,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) { '~setmobilealias': function(event) {
if(_.include(event.rUser.aliases, event.params[1])) { if(_.include(event.rUser.aliases, event.params[1])) {
if(!_.has(event.rUser, 'mobile')) event.rUser.mobile = []; if(!_.has(event.rUser, 'mobile')) event.rUser.mobile = [];

View File

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

View File

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