forked from GitHub/dbot
Activity indicator [#111]
This commit is contained in:
parent
4939446116
commit
c28047efc1
@ -38,7 +38,6 @@ 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];
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
var pages = function(dbot) {
|
var pages = function(dbot) {
|
||||||
|
var connections = dbot.instance.connections;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'/connections': function(req, res) {
|
'/connections': function(req, res) {
|
||||||
var connections = Object.keys(dbot.instance.connections);
|
var connections = Object.keys(dbot.instance.connections);
|
||||||
@ -23,23 +25,31 @@ var pages = function(dbot) {
|
|||||||
if(connections.hasOwnProperty(connection) &&
|
if(connections.hasOwnProperty(connection) &&
|
||||||
connections[connection].channels.hasOwnProperty(channel)) {
|
connections[connection].channels.hasOwnProperty(channel)) {
|
||||||
|
|
||||||
var nicks = dbot.db.knownUsers[connection].channelUsers[channel];
|
var channelUsers = dbot.db.knownUsers[connection].channelUsers[channel];
|
||||||
var channelUsers = {};
|
var usersData = {};
|
||||||
for(var i=0;i<nicks.length;i++) {
|
for(var i=0;i<channelUsers.length;i++) {
|
||||||
channelUsers[nicks[i]] = { 'name': nicks[i], 'online': false };
|
usersData[channelUsers[i]] = {
|
||||||
console.log(nicks[i]);
|
'name': channelUsers[i],
|
||||||
|
'online': false,
|
||||||
|
'active': false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var channelOnline = dbot.instance.connections[connection].channels[channel].nicks;
|
var onlineNicks = connections[connection].channels[channel].nicks;
|
||||||
channelOnline.each(function(nick) {
|
onlineNicks.each(function(nick) {
|
||||||
var nick = dbot.api.users.resolveUser(connection, nick);
|
var nick = dbot.api.users.resolveUser(connection, nick);
|
||||||
if(channelUsers.hasOwnProperty(nick)) {
|
if(onlineNicks.hasOwnProperty(nick)) {
|
||||||
channelUsers[nick].online = true;
|
usersData[nick].online = true;
|
||||||
}
|
}
|
||||||
|
/*usersData[nick].active = dbot.api.stats.isActive({
|
||||||
|
'server': connection,
|
||||||
|
'user': nick,
|
||||||
|
'channel': channel
|
||||||
|
});*/
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
res.render('users', { 'name': dbot.config.name, 'connection': connection,
|
res.render('users', { 'name': dbot.config.name, 'connection': connection,
|
||||||
'channel': channel, 'nicks': channelUsers });
|
'channel': channel, 'nicks': usersData });
|
||||||
} 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.' });
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ block content
|
|||||||
if nicks.hasOwnProperty(nick.name)
|
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)
|
||||||
if nick.online
|
if nick.online
|
||||||
li.quotes #{nick.name} (Online)
|
if nick.active
|
||||||
|
li.quotes #{nick.name} (Online, Active)
|
||||||
|
else
|
||||||
|
li.quotes #{nick.name} (Online, Inactive)
|
||||||
else
|
else
|
||||||
li.quotes #{nick.name} (Offline)
|
li.quotes #{nick.name} (Offline)
|
||||||
|
Loading…
Reference in New Issue
Block a user