show online status of known users in web + nick tracking fixes

This commit is contained in:
reality 2013-01-08 06:14:58 +00:00
parent eb526b18c5
commit 5f563f6c26
3 changed files with 27 additions and 7 deletions

View File

@ -38,13 +38,14 @@ var users = function(dbot) {
var knownUsers = getServerUsers(event.server);
if(!knownUsers.channelUsers.hasOwnProperty(event.channel.name)) {
knownUsers.channelUsers[event.channel.name] = [];
event.reply('creating new chanusers')
}
var channelUsers = knownUsers.channelUsers[event.channel.name];
event.channel.nicks.each(function(nick) {
nick = nick.name;
if(api.isKnownUser(event.server, nick)) {
nick = api.resolveUser(nick);
nick = api.resolveUser(event.server, nick);
} else {
knownUsers.users.push(nick);
}
@ -167,7 +168,7 @@ var users = function(dbot) {
var channelUsers = knownUsers.channelUsers[event.channel.name];
if(api.isKnownUser(event.server, nick)) {
nick = api.resolveUser(nick);
nick = api.resolveUser(event.server, nick);
} else {
knownUsers.users.push(nick);
}

View File

@ -22,9 +22,24 @@ var pages = function(dbot) {
if(connections.hasOwnProperty(connection) &&
connections[connection].channels.hasOwnProperty(channel)) {
var nicks = Object.keys(connections[connection].channels[channel].nicks);
var nicks = dbot.db.knownUsers[connection].channelUsers[channel];
var channelUsers = {};
for(var i=0;i<nicks.length;i++) {
channelUsers[nicks[i]] = { 'name': nicks[i], 'online': false };
console.log(nicks[i]);
}
var channelOnline = dbot.instance.connections[connection].channels[channel].nicks;
channelOnline.each(function(nick) {
var nick = dbot.api.users.resolveUser(connection, nick);
if(channelUsers.hasOwnProperty(nick)) {
channelUsers[nick].online = true;
}
}.bind(this));
res.render('users', { 'name': dbot.config.name, 'connection': connection,
'channel': channel, 'nicks': nicks });
'channel': channel, 'nicks': channelUsers });
} else {
res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection or channel.' });
}

View File

@ -1,10 +1,14 @@
extends ../layout
block content
h3 Users currently in #{channel} on #{connection}
h3 Users of #{channel} on #{connection}
div#backlink
a(href='/channels/'+connection) &laquo; Channel List
ul#quotelist
-each nick in nicks
if nicks.hasOwnProperty(nick.name)
a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick)
li.quotes #{nick}
if nick.online
li.quotes #{nick.name} (Online)
else
li.quotes #{nick.name} (Offline)