mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
some bug fixes
This commit is contained in:
parent
905ced9485
commit
8ba4db33a7
@ -1,7 +1,7 @@
|
||||
var _ = require('underscore')._;
|
||||
|
||||
var api = function(dbot) {
|
||||
this.api = {
|
||||
var api = {
|
||||
// Retrieve a user record given a server and nickname
|
||||
'resolveUser': function(server, nick, callback) {
|
||||
var id = nick + '.' + server;
|
||||
@ -62,6 +62,8 @@ var api = function(dbot) {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return api;
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
var _ = require('underscore')._;
|
||||
|
||||
var commands = function(dbot) {
|
||||
this.commands = {
|
||||
var commands = {
|
||||
'~alias': function(event) {
|
||||
var nick = event.params[1] || event.user;
|
||||
this.api.resolveUser(event.server, nick, function(err, user) {
|
||||
@ -124,10 +124,12 @@ var commands = function(dbot) {
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
this.commands['~setaliasparent'].access = 'moderator';
|
||||
this.commands['~addalias'].access = 'moderator';
|
||||
this.commands['~rmalias'].access = 'moderator';
|
||||
this.commands['~mergeusers'].access = 'moderator';
|
||||
commands['~setaliasparent'].access = 'moderator';
|
||||
commands['~addalias'].access = 'moderator';
|
||||
commands['~rmalias'].access = 'moderator';
|
||||
commands['~mergeusers'].access = 'moderator';
|
||||
|
||||
return commands;
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
|
@ -24,7 +24,7 @@ var users = function(dbot) {
|
||||
callback(true, null);
|
||||
}
|
||||
});
|
||||
},
|
||||
}.bind(this),
|
||||
|
||||
// Add new user alias
|
||||
'createAlias': function(alias, user, callback) {
|
||||
@ -41,7 +41,7 @@ var users = function(dbot) {
|
||||
callback(true, null);
|
||||
}
|
||||
});
|
||||
},
|
||||
}.bind(this),
|
||||
|
||||
// Remove an alias record
|
||||
'removeAlias': function(server, alias) {
|
||||
@ -49,7 +49,7 @@ var users = function(dbot) {
|
||||
this.db.del('user_aliases', id, function(err) {
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
}.bind(this),
|
||||
|
||||
// Update current nick of user record
|
||||
'updateCurrentNick': function(user, newNick, callback) {
|
||||
@ -62,7 +62,7 @@ var users = function(dbot) {
|
||||
callback(true, null);
|
||||
}
|
||||
});
|
||||
},
|
||||
}.bind(this),
|
||||
|
||||
// Merge two user records and aliases
|
||||
'mergeUsers': function(oldUser, newUser, callback) {
|
||||
@ -82,7 +82,7 @@ var users = function(dbot) {
|
||||
callback(true);
|
||||
}
|
||||
});
|
||||
},
|
||||
}.bind(this),
|
||||
|
||||
// Set a new nick as the parent for a user (so just recreate and merge)
|
||||
'reparentUser': function(user, newPrimary, callback) {
|
||||
@ -91,7 +91,7 @@ var users = function(dbot) {
|
||||
callback(err);
|
||||
});
|
||||
}.bind(this));
|
||||
}
|
||||
}.bind(this)
|
||||
};
|
||||
|
||||
/*** Listener ***/
|
||||
@ -114,7 +114,7 @@ var users = function(dbot) {
|
||||
|
||||
this.onLoad = function() {
|
||||
// Create non-existing users and update current nicks
|
||||
var checkUser = function(done) {
|
||||
var checkUser = function(event, done) {
|
||||
this.api.resolveUser(event.server, event.user, function(err, user) {
|
||||
if(!user) {
|
||||
this.internalAPI.createUser(event.server, event.user, done);
|
||||
@ -126,11 +126,11 @@ var users = function(dbot) {
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
}.bind(this);
|
||||
|
||||
dbot.instance.addPreEmitHook(function(event, callback) {
|
||||
if(event.user && _.include(['JOIN', 'PRIVMSG'], event.action)) {
|
||||
checkUser(function(err, user) {
|
||||
checkUser(event, function(err, user) {
|
||||
event.rUser = user;
|
||||
callback(null);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user