forked from GitHub/dbot
Efficiency improvements in users, return of isKnownUser API function [#331]
This commit is contained in:
parent
e426f4fae9
commit
da5e79ebeb
@ -93,6 +93,16 @@ var api = function(dbot) {
|
|||||||
callback(isOnline);
|
callback(isOnline);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'isKnownUser': function(server, nick, callback) {
|
||||||
|
this.api.resolveUser(server, nick, function(isKnown) {
|
||||||
|
if(isKnown == false) {
|
||||||
|
callback(false);
|
||||||
|
} else {
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"nl": "{alias} is een alias van {user}"
|
"nl": "{alias} is een alias van {user}"
|
||||||
},
|
},
|
||||||
"primary": {
|
"primary": {
|
||||||
"en": "{user} ({currentNick}) is a primary user with {count} aliases, ",
|
"en": "{user} (currently {currentNick}) is a primary user with {count} aliases, ",
|
||||||
"na'vi": "{user} ({currentNick}) lu txin ulte {count}a stxo lu poru, ",
|
"na'vi": "{user} ({currentNick}) lu txin ulte {count}a stxo lu poru, ",
|
||||||
"nl": "{user} ({currentNick}) is een primaire gebruiker met {count} aliassen, "
|
"nl": "{user} ({currentNick}) is een primaire gebruiker met {count} aliassen, "
|
||||||
},
|
},
|
||||||
|
@ -73,22 +73,34 @@ var users = function(dbot) {
|
|||||||
this.listener = function(event) {
|
this.listener = function(event) {
|
||||||
if(event.action == 'JOIN' && event.user != dbot.config.name) {
|
if(event.action == 'JOIN' && event.user != dbot.config.name) {
|
||||||
this.api.resolveUser(event.server, event.user, function(user) {
|
this.api.resolveUser(event.server, event.user, function(user) {
|
||||||
if(!user) { // User does not yet exist
|
var needsUpdating = false;
|
||||||
this.internalAPI.createUser(event.server, event.user, event.channel.name, function(result) {
|
|
||||||
this.internalAPI.addChannelUser(result, event.channel.name, function(err) { });
|
|
||||||
}.bind(this));
|
|
||||||
} else {
|
|
||||||
if(!_.include(user.channels, event.channel.name)) { // User not yet channel user
|
|
||||||
user.channels.push(event.channel.name);
|
|
||||||
this.internalAPI.addChannelUser(user, event.channel.name, function(err) { });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(!user) { // User does not yet exist
|
||||||
|
user = {
|
||||||
|
'id': uuid.v4(),
|
||||||
|
'primaryNick': event.user,
|
||||||
|
'currentNick': event.user,
|
||||||
|
'server': event.server,
|
||||||
|
'channels': [],
|
||||||
|
'aliases': []
|
||||||
|
};
|
||||||
|
this.internalAPI.addChannelUser(user, event.channel.name, function(err) { });
|
||||||
|
needsUpdating = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!_.include(user.channels, event.channel.name)) { // User not yet channel user
|
||||||
|
user.channels.push(event.channel.name);
|
||||||
|
this.internalAPI.addChannelUser(user, event.channel.name, function(err) { });
|
||||||
|
needsUpdating = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(user.currentNick != event.user) {
|
||||||
user.currentNick = event.user;
|
user.currentNick = event.user;
|
||||||
this.db.save('users', user.id, user, function(err) {
|
needsUpdating = true;
|
||||||
if(err) {
|
}
|
||||||
// QQ
|
|
||||||
}
|
if(needsUpdating == true) {
|
||||||
});
|
this.db.save('users', user.id, user, function(err) { });
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
} else if(event.action == 'NICK') {
|
} else if(event.action == 'NICK') {
|
||||||
|
Loading…
Reference in New Issue
Block a user