2013-01-07 13:27:24 +01:00
|
|
|
var pages = function(dbot) {
|
2013-01-09 06:53:45 +01:00
|
|
|
var connections = dbot.instance.connections;
|
|
|
|
|
2013-01-07 13:27:24 +01:00
|
|
|
return {
|
|
|
|
'/connections': function(req, res) {
|
|
|
|
var connections = Object.keys(dbot.instance.connections);
|
|
|
|
res.render('connections', { 'name': dbot.config.name, 'connections': connections });
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channels/:connection': function(req, res) {
|
|
|
|
var connection = req.params.connection;
|
|
|
|
if(dbot.instance.connections.hasOwnProperty(connection)) {
|
|
|
|
var channels = Object.keys(dbot.instance.connections[connection].channels);
|
|
|
|
res.render('channels', { 'name': dbot.config.name, 'connection': connection, 'channels': channels});
|
|
|
|
} else {
|
|
|
|
res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection.' });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'/users/:connection/:channel': function(req, res) {
|
|
|
|
var connection = req.params.connection;
|
|
|
|
var channel = '#' + req.params.channel;
|
|
|
|
var connections = dbot.instance.connections;
|
|
|
|
|
|
|
|
if(connections.hasOwnProperty(connection) &&
|
|
|
|
connections[connection].channels.hasOwnProperty(channel)) {
|
2013-01-08 07:14:58 +01:00
|
|
|
|
2013-01-09 06:53:45 +01:00
|
|
|
var channelUsers = dbot.db.knownUsers[connection].channelUsers[channel];
|
|
|
|
var usersData = {};
|
|
|
|
for(var i=0;i<channelUsers.length;i++) {
|
|
|
|
usersData[channelUsers[i]] = {
|
|
|
|
'name': channelUsers[i],
|
|
|
|
'online': false,
|
|
|
|
'active': false
|
|
|
|
};
|
2013-01-08 07:14:58 +01:00
|
|
|
}
|
|
|
|
|
2013-01-09 06:53:45 +01:00
|
|
|
var onlineNicks = connections[connection].channels[channel].nicks;
|
|
|
|
onlineNicks.each(function(nick) {
|
2013-01-08 07:14:58 +01:00
|
|
|
var nick = dbot.api.users.resolveUser(connection, nick);
|
2013-01-09 06:53:45 +01:00
|
|
|
if(onlineNicks.hasOwnProperty(nick)) {
|
|
|
|
usersData[nick].online = true;
|
2013-01-08 07:14:58 +01:00
|
|
|
}
|
2013-01-09 06:53:45 +01:00
|
|
|
/*usersData[nick].active = dbot.api.stats.isActive({
|
|
|
|
'server': connection,
|
|
|
|
'user': nick,
|
|
|
|
'channel': channel
|
|
|
|
});*/
|
2013-01-08 07:14:58 +01:00
|
|
|
}.bind(this));
|
|
|
|
|
2013-01-07 13:27:24 +01:00
|
|
|
res.render('users', { 'name': dbot.config.name, 'connection': connection,
|
2013-01-09 06:53:45 +01:00
|
|
|
'channel': channel, 'nicks': usersData });
|
2013-01-07 13:27:24 +01:00
|
|
|
} else {
|
|
|
|
res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection or channel.' });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'/user/:connection/:channel/:user': function(req, res) {
|
|
|
|
var connection = req.params.connection;
|
|
|
|
var channel = '#' + req.params.channel;
|
|
|
|
var user = dbot.cleanNick(req.params.user);
|
|
|
|
|
|
|
|
var quoteCount = 'no';
|
|
|
|
if(dbot.db.quoteArrs.hasOwnProperty(user)) {
|
|
|
|
var quoteCount = dbot.db.quoteArrs[user].length;
|
|
|
|
}
|
|
|
|
|
2013-01-09 07:05:01 +01:00
|
|
|
if(dbot.config.moduleNames.include('kick')) {
|
|
|
|
if(!dbot.db.kicks.hasOwnProperty(req.params.user)) {
|
|
|
|
var kicks = '0';
|
|
|
|
} else {
|
|
|
|
var kicks = dbot.db.kicks[req.params.user];
|
|
|
|
}
|
2013-01-07 13:27:24 +01:00
|
|
|
|
2013-01-09 07:05:01 +01:00
|
|
|
if(!dbot.db.kickers.hasOwnProperty(req.params.user)) {
|
|
|
|
var kicked = '0';
|
|
|
|
} else {
|
|
|
|
var kicked = dbot.db.kickers[req.params.user];
|
|
|
|
}
|
2013-01-07 13:27:24 +01:00
|
|
|
} else {
|
2013-01-09 07:05:01 +01:00
|
|
|
var kicks = 'N/A';
|
|
|
|
var kicked = 'N/A';
|
2013-01-07 13:27:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
res.render('user', { 'name': dbot.config.name, 'user': req.params.user,
|
|
|
|
'channel': channel, 'connection': connection, 'cleanUser': user,
|
|
|
|
'quotecount': quoteCount, 'kicks': kicks, 'kicked': kicked });
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.getPages = function(dbot) {
|
|
|
|
return pages(dbot);
|
|
|
|
};
|