mirror of
https://github.com/reality/dbot.git
synced 2024-11-24 04:49:25 +01:00
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
|
var _ = require('underscore')._;
|
||
|
|
||
|
var pages = function(dbot) {
|
||
|
return {
|
||
|
'/warnings': function(req, res) {
|
||
|
res.render('warnings_servers', {
|
||
|
'name': dbot.config.name,
|
||
|
'servers': _.keys(this.warnings)
|
||
|
});
|
||
|
},
|
||
|
|
||
|
'/warnings/:server': function(req, res) {
|
||
|
var server = req.params.server;
|
||
|
|
||
|
if(_.has(this.warnings, server)) {
|
||
|
res.render('warnings_users', {
|
||
|
'name': dbot.config.name,
|
||
|
'users': _.keys(this.warnings[server])
|
||
|
});
|
||
|
} else {
|
||
|
res.render('error');
|
||
|
}
|
||
|
},
|
||
|
|
||
|
'/warnings/:server/:user': function(req, res) {
|
||
|
var server = req.params.server,
|
||
|
user = req.params.user;
|
||
|
|
||
|
if(_.has(this.warnings, server) && _.has(this.warnings.server, user)) {
|
||
|
res.render('warnings', {
|
||
|
'name': dbot.config.name,
|
||
|
'warnings': this.warnings[server][user]
|
||
|
});
|
||
|
} else {
|
||
|
res.render('error');
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
exports.fetch = function(dbot) {
|
||
|
return pages(dbot);
|
||
|
};
|