forked from GitHub/dbot
show online status of known users in web + nick tracking fixes
This commit is contained in:
parent
eb526b18c5
commit
5f563f6c26
@ -38,13 +38,14 @@ var users = function(dbot) {
|
|||||||
var knownUsers = getServerUsers(event.server);
|
var knownUsers = getServerUsers(event.server);
|
||||||
if(!knownUsers.channelUsers.hasOwnProperty(event.channel.name)) {
|
if(!knownUsers.channelUsers.hasOwnProperty(event.channel.name)) {
|
||||||
knownUsers.channelUsers[event.channel.name] = [];
|
knownUsers.channelUsers[event.channel.name] = [];
|
||||||
|
event.reply('creating new chanusers')
|
||||||
}
|
}
|
||||||
var channelUsers = knownUsers.channelUsers[event.channel.name];
|
var channelUsers = knownUsers.channelUsers[event.channel.name];
|
||||||
|
|
||||||
event.channel.nicks.each(function(nick) {
|
event.channel.nicks.each(function(nick) {
|
||||||
nick = nick.name;
|
nick = nick.name;
|
||||||
if(api.isKnownUser(event.server, nick)) {
|
if(api.isKnownUser(event.server, nick)) {
|
||||||
nick = api.resolveUser(nick);
|
nick = api.resolveUser(event.server, nick);
|
||||||
} else {
|
} else {
|
||||||
knownUsers.users.push(nick);
|
knownUsers.users.push(nick);
|
||||||
}
|
}
|
||||||
@ -167,7 +168,7 @@ var users = function(dbot) {
|
|||||||
var channelUsers = knownUsers.channelUsers[event.channel.name];
|
var channelUsers = knownUsers.channelUsers[event.channel.name];
|
||||||
|
|
||||||
if(api.isKnownUser(event.server, nick)) {
|
if(api.isKnownUser(event.server, nick)) {
|
||||||
nick = api.resolveUser(nick);
|
nick = api.resolveUser(event.server, nick);
|
||||||
} else {
|
} else {
|
||||||
knownUsers.users.push(nick);
|
knownUsers.users.push(nick);
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,24 @@ var pages = function(dbot) {
|
|||||||
|
|
||||||
if(connections.hasOwnProperty(connection) &&
|
if(connections.hasOwnProperty(connection) &&
|
||||||
connections[connection].channels.hasOwnProperty(channel)) {
|
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,
|
res.render('users', { 'name': dbot.config.name, 'connection': connection,
|
||||||
'channel': channel, 'nicks': nicks });
|
'channel': channel, 'nicks': channelUsers });
|
||||||
} else {
|
} else {
|
||||||
res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection or channel.' });
|
res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection or channel.' });
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
extends ../layout
|
extends ../layout
|
||||||
|
|
||||||
block content
|
block content
|
||||||
h3 Users currently in #{channel} on #{connection}
|
h3 Users of #{channel} on #{connection}
|
||||||
div#backlink
|
div#backlink
|
||||||
a(href='/channels/'+connection) « Channel List
|
a(href='/channels/'+connection) « Channel List
|
||||||
ul#quotelist
|
ul#quotelist
|
||||||
-each nick in nicks
|
-each nick in nicks
|
||||||
|
if nicks.hasOwnProperty(nick.name)
|
||||||
a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user