mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 22:39:26 +01:00
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);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
'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}"
|
||||
},
|
||||
"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, ",
|
||||
"nl": "{user} ({currentNick}) is een primaire gebruiker met {count} aliassen, "
|
||||
},
|
||||
|
@ -73,22 +73,34 @@ var users = function(dbot) {
|
||||
this.listener = function(event) {
|
||||
if(event.action == 'JOIN' && event.user != dbot.config.name) {
|
||||
this.api.resolveUser(event.server, event.user, function(user) {
|
||||
var needsUpdating = false;
|
||||
|
||||
if(!user) { // User does not yet exist
|
||||
this.internalAPI.createUser(event.server, event.user, event.channel.name, function(result) {
|
||||
this.internalAPI.addChannelUser(result, event.channel.name, function(err) { });
|
||||
}.bind(this));
|
||||
} else {
|
||||
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;
|
||||
this.db.save('users', user.id, user, function(err) {
|
||||
if(err) {
|
||||
// QQ
|
||||
needsUpdating = true;
|
||||
}
|
||||
});
|
||||
|
||||
if(needsUpdating == true) {
|
||||
this.db.save('users', user.id, user, function(err) { });
|
||||
}
|
||||
}.bind(this));
|
||||
} else if(event.action == 'NICK') {
|
||||
|
Loading…
Reference in New Issue
Block a user